Previous 15994 Revisions Next

r7483 Wednesday 3rd March, 2010 at 10:46:44 UTC by Firewave
removed obsolete files
[src/mame/drivers]ddrible.c megadriv.h segamsys.h
[src/mame/includes]ddrible.h
[src/mame/machine]system16.c
[src/mame/video]ddrible.c hd63484.c hd63484.h sys16spr.c

src/mame/machine/system16.c
r7482r7483
1#include "emu.h"
2#include "includes/system16.h"
3#include "sound/upd7759.h"
4
5static void patch_codeX( UINT16 *mem, offs_t offset, int data )
6{
7   int aligned_offset = offset&0xfffffe;
8   int old_word = mem[aligned_offset/2];
9
10   if( offset&1 )
11      data = (old_word&0xff00)|data;
12   else
13      data = (old_word&0x00ff)|(data<<8);
14
15   mem[aligned_offset/2] = data;
16}
17
18void sys16_patch_code( running_machine *machine, const sys16_patch *data, int count )
19{
20   int i;
21   UINT16 *mem = (UINT16 *)memory_region(machine, "maincpu");
22   for (i=0; i<count; i++)
23      patch_codeX(mem, data[i].offset, data[i].data);
24}
25
26
27MACHINE_RESET( sys16_onetime )
28{
29   sys16_bg1_trans=0;
30   sys16_rowscroll_scroll=0;
31   sys18_splittab_bg_x=0;
32   sys18_splittab_bg_y=0;
33   sys18_splittab_fg_x=0;
34   sys18_splittab_fg_y=0;
35}
36
37static const gfx_layout charlayout =
38{
39   8,8,
40   RGN_FRAC(1,3),
41   3,
42   { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
43   { 0, 1, 2, 3, 4, 5, 6, 7 },
44   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
45   8*8
46};
47
48GFXDECODE_START( sys16 )
49   GFXDECODE_ENTRY( "gfx1", 0, charlayout,   0, 1024 )
50GFXDECODE_END
51
52
53/* sound */
54
55static void sound_cause_nmi( running_device *device, int chip )
56{
57   /* upd7759 callback */
58   cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
59}
60
61
62const upd7759_interface sys16_upd7759_interface =
63{
64   sound_cause_nmi
65};
66
67int sys18_sound_info[4*2];
68
src/mame/includes/ddrible.h
r7482r7483
1/***************************************************************************
2
3    Double Dribble
4
5***************************************************************************/
6
7typedef struct _ddrible_state ddrible_state;
8struct _ddrible_state
9{
10   /* memory pointers */
11   UINT8 *     sharedram;
12   UINT8 *     snd_sharedram;
13   UINT8 *     spriteram_1;
14   UINT8 *     spriteram_2;
15   UINT8 *     bg_videoram;
16   UINT8 *     fg_videoram;
17   UINT8 *     paletteram;
18
19   /* video-related */
20   tilemap_t     *fg_tilemap,*bg_tilemap;
21   int         vregs[2][5];
22   int         charbank[2];
23
24   /* misc */
25   int         int_enable_0, int_enable_1;
26
27   /* devices */
28   running_device *filter1;
29   running_device *filter2;
30   running_device *filter3;
31};
32
33/*----------- defined in video/ddrible.c -----------*/
34
35WRITE8_HANDLER( ddrible_fg_videoram_w );
36WRITE8_HANDLER( ddrible_bg_videoram_w );
37WRITE8_HANDLER( K005885_0_w );
38WRITE8_HANDLER( K005885_1_w );
39
40PALETTE_INIT( ddrible );
41VIDEO_START( ddrible );
42VIDEO_UPDATE( ddrible );
src/mame/video/hd63484.c
r7482r7483
1/***************************************************************************
2
3hd63484
4
5this chip is used in:
6- shanghai.c
7- adp.c
8
9***************************************************************************/
10
11#include "emu.h"
12#include "video/hd63484.h"
13
14#define LOG_COMMANDS 0
15
16static int get_pixel(int x,int y);
17
18/* the on-chip FIFO is 16 bytes long, but we use a larger one to simplify */
19/* decoding of long commands. Commands can be up to 64KB long... but Shanghai */
20/* doesn't reach that length. */
21
22#define FIFO_LENGTH 256
23
24static int fifo_counter;
25static UINT16 fifo[FIFO_LENGTH];
26static UINT16 readfifo;
27UINT16 *HD63484_ram;
28UINT16 HD63484_reg[256/2];
29static UINT16 pattern[16];
30static int org,org_dpd,rwp;
31static UINT16 cl0,cl1,ccmp,edg,mask,ppy,pzcy,ppx,pzcx,psy,psx,pey,pzy,pex,pzx,xmin,ymin,xmax,ymax,rwp_dn;
32static INT16 cpx,cpy;
33
34static const int instruction_length[64] =
35{
36    0, 3, 2, 1,   /* 0x */
37    0, 0,-1, 2,   /* 1x */
38    0, 3, 3, 3,   /* 2x */
39    0, 0, 0, 0,   /* 3x */
40    0, 1, 2, 2,   /* 4x */
41    0, 0, 4, 4,   /* 5x */
42    5, 5, 5, 5,   /* 6x */
43    5, 5, 5, 5,   /* 7x */
44    3, 3, 3, 3,   /* 8x */
45    3, 3,-2,-2,   /* 9x */
46   -2,-2, 2, 4,   /* Ax */
47    5, 5, 7, 7,   /* Bx */
48    3, 3, 1, 1,   /* Cx */
49    2, 2, 2, 2,   /* Dx */
50    5, 5, 5, 5,   /* Ex */
51    5, 5, 5, 5    /* Fx */
52};
53
54static const char *const instruction_name[64] =
55{
56   "undef","ORG  ","WPR  ","RPR  ",   /* 0x */
57   "undef","undef","WPTN ","RPTN ",   /* 1x */
58   "undef","DRD  ","DWT  ","DMOD ",   /* 2x */
59   "undef","undef","undef","undef",   /* 3x */
60   "undef","RD   ","WT   ","MOD  ",   /* 4x */
61   "undef","undef","CLR  ","SCLR ",   /* 5x */
62   "CPY  ","CPY  ","CPY  ","CPY  ",   /* 6x */
63   "SCPY ","SCPY ","SCPY ","SCPY ",   /* 7x */
64   "AMOVE","RMOVE","ALINE","RLINE",   /* 8x */
65   "ARCT ","RRCT ","APLL ","RPLL ",   /* 9x */
66   "APLG ","RPLG ","CRCL ","ELPS ",   /* Ax */
67   "AARC ","RARC ","AEARC","REARC",   /* Bx */
68   "AFRCT","RFRCT","PAINT","DOT  ",   /* Cx */
69   "PTN  ","PTN  ","PTN  ","PTN  ",   /* Dx */
70   "AGCPY","AGCPY","AGCPY","AGCPY",   /* Ex */
71   "RGCPY","RGCPY","RGCPY","RGCPY"    /* Fx */
72};
73
74void HD63484_start(running_machine *machine)
75{
76   fifo_counter = 0;
77   HD63484_ram = auto_alloc_array_clear(machine, UINT16, HD63484_RAM_SIZE);
78}
79
80static void doclr16(int opcode,UINT16 fill,int *dst,INT16 _ax,INT16 _ay)
81{
82   INT16 ax,ay;
83
84   ax = _ax;
85   ay = _ay;
86
87   for (;;)
88   {
89      for (;;)
90      {
91         switch (opcode & 0x0003)
92         {
93            case 0:
94               HD63484_ram[*dst]  = fill;
95               break;
96            case 1:
97               HD63484_ram[*dst] |= fill;
98               break;
99            case 2:
100               HD63484_ram[*dst] &= fill;
101               break;
102            case 3:
103               HD63484_ram[*dst] ^= fill;
104               break;
105         }
106         if (ax == 0) break;
107         else if (ax > 0)
108         {
109            *dst = (*dst + 1) & (HD63484_RAM_SIZE-1);
110            ax--;
111         }
112         else
113         {
114            *dst = (*dst - 1) & (HD63484_RAM_SIZE-1);
115            ax++;
116         }
117      }
118
119      ax = _ax;
120      if (_ay < 0)
121      {
122         *dst = (*dst + (HD63484_reg[0xca/2] & 0x0fff) - ax) & (HD63484_RAM_SIZE-1);
123         if (ay == 0) break;
124         ay++;
125      }
126      else
127      {
128         *dst = (*dst - (HD63484_reg[0xca/2] & 0x0fff) - ax) & (HD63484_RAM_SIZE-1);
129         if (ay == 0) break;
130         ay--;
131      }
132   }
133}
134
135static void docpy16(int opcode,int src,int *dst,INT16 _ax,INT16 _ay)
136{
137   int dstep1,dstep2;
138   int ax = _ax;
139   int ay = _ay;
140
141   switch (opcode & 0x0700)
142   {
143      default:
144      case 0x0000: dstep1 =  1; dstep2 = -1 * (HD63484_reg[0xca/2] & 0x0fff) - ax * dstep1; break;
145      case 0x0100: dstep1 =  1; dstep2 =      (HD63484_reg[0xca/2] & 0x0fff) - ax * dstep1; break;
146      case 0x0200: dstep1 = -1; dstep2 = -1 * (HD63484_reg[0xca/2] & 0x0fff) + ax * dstep1; break;
147      case 0x0300: dstep1 = -1; dstep2 =      (HD63484_reg[0xca/2] & 0x0fff) + ax * dstep1; break;
148      case 0x0400: dstep1 = -1 * (HD63484_reg[0xca/2] & 0x0fff); dstep2 =  1 - ay * dstep1; break;
149      case 0x0500: dstep1 =      (HD63484_reg[0xca/2] & 0x0fff); dstep2 =  1 - ay * dstep1; break;
150      case 0x0600: dstep1 = -1 * (HD63484_reg[0xca/2] & 0x0fff); dstep2 = -1 + ay * dstep1; break;
151      case 0x0700: dstep1 =      (HD63484_reg[0xca/2] & 0x0fff); dstep2 = -1 + ay * dstep1; break;
152   }
153
154   for (;;)
155   {
156      for (;;)
157      {
158         switch (opcode & 0x0007)
159         {
160            case 0:
161               HD63484_ram[*dst]  = HD63484_ram[src];
162               break;
163            case 1:
164               HD63484_ram[*dst] |= HD63484_ram[src];
165               break;
166            case 2:
167               HD63484_ram[*dst] &= HD63484_ram[src];
168               break;
169            case 3:
170               HD63484_ram[*dst] ^= HD63484_ram[src];
171               break;
172            case 4:
173               if (HD63484_ram[*dst] == (ccmp & 0xff))
174                  HD63484_ram[*dst] = HD63484_ram[src];
175               break;
176            case 5:
177               if (HD63484_ram[*dst] != (ccmp & 0xff))
178                  HD63484_ram[*dst] = HD63484_ram[src];
179               break;
180            case 6:
181               if (HD63484_ram[*dst] < HD63484_ram[src])
182                  HD63484_ram[*dst] = HD63484_ram[src];
183               break;
184            case 7:
185               if (HD63484_ram[*dst] > HD63484_ram[src])
186                  HD63484_ram[*dst] = HD63484_ram[src];
187               break;
188         }
189
190         if (opcode & 0x0800)
191         {
192            if (ay == 0) break;
193            if (_ay > 0)
194            {
195               src = (src - (HD63484_reg[0xca/2] & 0x0fff)) & (HD63484_RAM_SIZE-1);
196               *dst = (*dst + dstep1) & (HD63484_RAM_SIZE-1);
197               ay--;
198            }
199            else
200            {
201               src = (src + (HD63484_reg[0xca/2] & 0x0fff)) & (HD63484_RAM_SIZE-1);
202               *dst = (*dst + dstep1) & (HD63484_RAM_SIZE-1);
203               ay++;
204            }
205         }
206         else
207         {
208            if (ax == 0) break;
209            else if (ax > 0)
210            {
211               src = (src + 1) & (HD63484_RAM_SIZE-1);
212               *dst = (*dst + dstep1) & (HD63484_RAM_SIZE-1);
213               ax--;
214            }
215            else
216            {
217               src = (src - 1) & (HD63484_RAM_SIZE-1);
218               *dst = (*dst + dstep1) & (HD63484_RAM_SIZE-1);
219               ax++;
220            }
221         }
222      }
223
224      if (opcode & 0x0800)
225      {
226         ay = _ay;
227         if (_ax < 0)
228         {
229            src = (src - 1 + ay * (HD63484_reg[0xca/2] & 0x0fff)) & (HD63484_RAM_SIZE-1);
230            *dst = (*dst + dstep2) & (HD63484_RAM_SIZE-1);
231            if (ax == 0) break;
232            ax++;
233         }
234         else
235         {
236            src = (src + 1 - ay * (HD63484_reg[0xca/2] & 0x0fff)) & (HD63484_RAM_SIZE-1);
237            *dst = (*dst + dstep2) & (HD63484_RAM_SIZE-1);
238            if (ax == 0) break;
239            ax--;
240         }
241      }
242      else
243      {
244         ax = _ax;
245         if (_ay < 0)
246         {
247            src = (src + (HD63484_reg[0xca/2] & 0x0fff) - ax) & (HD63484_RAM_SIZE-1);
248            *dst = (*dst + dstep2) & (HD63484_RAM_SIZE-1);
249            if (ay == 0) break;
250            ay++;
251         }
252         else
253         {
254            src = (src - (HD63484_reg[0xca/2] & 0x0fff) - ax) & (HD63484_RAM_SIZE-1);
255            *dst = (*dst + dstep2) & (HD63484_RAM_SIZE-1);
256            if (ay == 0) break;
257            ay--;
258         }
259      }
260   }
261}
262
263static int org_first_pixel(int _org_dpd)
264{
265   int gbm = (HD63484_reg[0x02/2] & 0x700) >> 8;
266
267   switch (gbm)
268   {
269      case 0:
270         return (_org_dpd & 0x0f);
271      case 1:
272         return (_org_dpd & 0x0e) >> 1;
273      case 2:
274         return (_org_dpd & 0x0c) >> 2;
275      case 3:
276         return (_org_dpd & 0x08) >> 3;
277      case 4:
278         return 0;
279
280      default:
281         logerror ("Graphic bit mode not supported\n");
282         return 0;
283   }
284}
285
286static void dot(int x, int y, int opm, UINT16 color)
287{
288   int dst, x_int, x_mod, bpp;
289   UINT16 color_shifted, bitmask, bitmask_shifted;
290
291   x += org_first_pixel(org_dpd);
292
293   switch ((HD63484_reg[0x02/2] & 0x700) >> 8)
294   {
295      case 0:
296         bpp = 1;
297         bitmask = 0x0001;
298         break;
299      case 1:
300         bpp = 2;
301         bitmask = 0x0003;
302         break;
303      case 2:
304         bpp = 4;
305         bitmask = 0x000f;
306         break;
307      case 3:
308         bpp = 8;
309         bitmask = 0x00ff;
310         break;
311      case 4:
312         bpp = 16;
313         bitmask = 0xffff;
314         break;
315
316      default:
317         bpp = 0;
318         bitmask = 0x0000;
319         logerror ("Graphic bit mode not supported\n");
320   }
321
322   // bpp = 4;          // for skattva
323   // bitmask = 0x000f; // for skattva
324
325   if (x >= 0)
326   {
327      x_int = x / (16 / bpp);
328      x_mod = x % (16 / bpp);
329   }
330   else
331   {
332      x_int = x / (16 / bpp);
333      x_mod = -1 * (x % (16 / bpp));
334      if (x_mod) {
335         x_int--;
336         x_mod = (16 / bpp) - x_mod;
337      }
338   }
339
340   color &= bitmask;
341
342   bitmask_shifted = bitmask << (x_mod * bpp);
343   color_shifted = color << (x_mod * bpp);
344
345   dst = (org + x_int - y * (HD63484_reg[0xca/2] & 0x0fff)) & (HD63484_RAM_SIZE-1);
346
347   switch (opm)
348   {
349      case 0:
350         HD63484_ram[dst] = (HD63484_ram[dst] & ~bitmask_shifted) | color_shifted;
351         break;
352      case 1:
353         HD63484_ram[dst] = HD63484_ram[dst] | color_shifted;
354         break;
355      case 2:
356         HD63484_ram[dst] = HD63484_ram[dst] & ((HD63484_ram[dst] & ~bitmask_shifted) | color_shifted);
357         break;
358      case 3:
359         HD63484_ram[dst] = HD63484_ram[dst] ^ color_shifted;
360         break;
361      case 4:
362         if (get_pixel(x,y) == (ccmp & bitmask))
363            HD63484_ram[dst] = (HD63484_ram[dst] & ~bitmask_shifted) | color_shifted;
364         break;
365      case 5:
366         if (get_pixel(x,y) != (ccmp & bitmask))
367            HD63484_ram[dst] = (HD63484_ram[dst] & ~bitmask_shifted) | color_shifted;
368         break;
369      case 6:
370         if (get_pixel(x,y) < (cl0 & bitmask))
371            HD63484_ram[dst] = (HD63484_ram[dst] & ~bitmask_shifted) | color_shifted;
372         break;
373      case 7:
374         if (get_pixel(x,y) > (cl0 & bitmask))
375            HD63484_ram[dst] = (HD63484_ram[dst] & ~bitmask_shifted) | color_shifted;
376         break;
377   }
378}
379
380static int get_pixel(int x,int y)
381{
382   int dst, x_int, x_mod, bpp;
383   UINT16 bitmask, bitmask_shifted;
384
385   switch ((HD63484_reg[0x02/2] & 0x700) >> 8)
386   {
387      case 0:
388         bpp = 1;
389         bitmask = 0x0001;
390         break;
391      case 1:
392         bpp = 2;
393         bitmask = 0x0003;
394         break;
395      case 2:
396         bpp = 4;
397         bitmask = 0x000f;
398         break;
399      case 3:
400         bpp = 8;
401         bitmask = 0x00ff;
402         break;
403      case 4:
404         bpp = 16;
405         bitmask = 0xffff;
406         break;
407
408      default:
409         bpp = 0;
410         bitmask = 0x0000;
411         logerror ("Graphic bit mode not supported\n");
412   }
413   if (x >= 0)
414   {
415      x_int = x / (16 / bpp);
416      x_mod = x % (16 / bpp);
417   }
418   else
419   {
420      x_int = x / (16 / bpp);
421      x_mod = -1 * (x % (16 / bpp));
422      if (x_mod) {
423         x_int--;
424         x_mod = (16 / bpp) - x_mod;
425      }
426   }
427
428   bitmask_shifted = bitmask << (x_mod * bpp);
429
430   dst = (org + x_int - y * (HD63484_reg[0xca/2] & 0x0fff)) & (HD63484_RAM_SIZE-1);
431
432   return ((HD63484_ram[dst] & bitmask_shifted) >> (x_mod * bpp));
433}
434
435static int get_pixel_ptn(int x,int y)
436{
437   int dst, x_int, x_mod, bpp;
438   UINT16 bitmask, bitmask_shifted;
439
440   bpp = 1;
441   bitmask = 0x0001;
442
443   if (x >= 0)
444   {
445      x_int = x / (16 / bpp);
446      x_mod = x % (16 / bpp);
447   }
448   else
449   {
450      x_int = x / (16 / bpp);
451      x_mod = -1 * (x % (16 / bpp));
452      if (x_mod) {
453         x_int--;
454         x_mod = (16 / bpp) - x_mod;
455      }
456   }
457
458   bitmask_shifted = bitmask << (x_mod * bpp);
459
460   dst = (x_int + y * 1);
461
462   if ((pattern[dst] & bitmask_shifted) >> (x_mod * bpp))
463      return 1;
464   else
465      return 0;
466}
467
468static void agcpy(int opcode,int src_x,int src_y,int dst_x,int dst_y,INT16 _ax,INT16 _ay)
469{
470   int dst_step1_x,dst_step1_y,dst_step2_x,dst_step2_y;
471   int src_step1_x,src_step1_y,src_step2_x,src_step2_y;
472   int ax_neg,ay_neg;
473   int ax = _ax;
474   int ay = _ay;
475   int xxs = src_x;
476   int yys = src_y;
477   int xxd = dst_x;
478   int yyd = dst_y;
479
480   if (ax < 0)
481      ax_neg = -1;
482   else
483      ax_neg = 1;
484   if (ay < 0)
485      ay_neg = -1;
486   else
487      ay_neg = 1;
488
489   if (opcode & 0x0800)
490      switch (opcode & 0x0700)
491      {
492         default:
493         case 0x0000: dst_step1_x =  1; dst_step1_y =  0; dst_step2_x = -ay_neg*ay; dst_step2_y =   1; break;
494         case 0x0100: dst_step1_x =  1; dst_step1_y =  0; dst_step2_x = -ay_neg*ay; dst_step2_y =  -1; break;
495         case 0x0200: dst_step1_x = -1; dst_step1_y =  0; dst_step2_x =  ay_neg*ay; dst_step2_y =   1; break;
496         case 0x0300: dst_step1_x = -1; dst_step1_y =  0; dst_step2_x =  ay_neg*ay; dst_step2_y =  -1; break;
497         case 0x0400: dst_step1_x =  0; dst_step1_y =  1; dst_step2_x =  1; dst_step2_y = -ay_neg*ay; break;
498         case 0x0500: dst_step1_x =  0; dst_step1_y = -1; dst_step2_x =  1; dst_step2_y =  ay_neg*ay; break;
499         case 0x0600: dst_step1_x =  0; dst_step1_y =  1; dst_step2_x = -1; dst_step2_y = -ay_neg*ay; break;
500         case 0x0700: dst_step1_x =  0; dst_step1_y = -1; dst_step2_x = -1; dst_step2_y =  ay_neg*ay; break;
501      }
502   else
503      switch (opcode & 0x0700)
504      {
505         default:
506         case 0x0000: dst_step1_x =  1; dst_step1_y =  0; dst_step2_x = -ax_neg*ax; dst_step2_y =   1; break;
507         case 0x0100: dst_step1_x =  1; dst_step1_y =  0; dst_step2_x = -ax_neg*ax; dst_step2_y =  -1; break;
508         case 0x0200: dst_step1_x = -1; dst_step1_y =  0; dst_step2_x =  ax_neg*ax; dst_step2_y =   1; break;
509         case 0x0300: dst_step1_x = -1; dst_step1_y =  0; dst_step2_x =  ax_neg*ax; dst_step2_y =  -1; break;
510         case 0x0400: dst_step1_x =  0; dst_step1_y =  1; dst_step2_x =  1; dst_step2_y =  ax_neg*ax; break;
511         case 0x0500: dst_step1_x =  0; dst_step1_y = -1; dst_step2_x =  1; dst_step2_y = -ax_neg*ax; break;
512         case 0x0600: dst_step1_x =  0; dst_step1_y =  1; dst_step2_x = -1; dst_step2_y =  ax_neg*ax; break;
513         case 0x0700: dst_step1_x =  0; dst_step1_y = -1; dst_step2_x = -1; dst_step2_y = -ax_neg*ax; break;
514      }
515
516   if ((_ax >= 0) && (_ay >= 0) && ((opcode & 0x0800) == 0x0000))
517      { src_step1_x =  1; src_step1_y =  0; src_step2_x = -ax; src_step2_y =   1; }
518   else if ((_ax >= 0) && (_ay < 0) && ((opcode & 0x0800) == 0x0000))
519      { src_step1_x =  1; src_step1_y =  0; src_step2_x = -ax; src_step2_y =  -1; }
520   else if ((_ax < 0) && (_ay >= 0) && ((opcode & 0x0800) == 0x0000))
521      { src_step1_x = -1; src_step1_y =  0; src_step2_x = -ax; src_step2_y =   1; }
522   else if ((_ax < 0) && (_ay < 0) && ((opcode & 0x0800) == 0x0000))
523      { src_step1_x = -1; src_step1_y =  0; src_step2_x = -ax; src_step2_y =  -1; }
524   else if ((_ax >= 0) && (_ay >= 0) && ((opcode & 0x0800) == 0x0800))
525      { src_step1_x =  0; src_step1_y =  1; src_step2_x =   1; src_step2_y = -ay; }
526   else if ((_ax >= 0) && (_ay < 0) && ((opcode & 0x0800) == 0x0800))
527      { src_step1_x =  0; src_step1_y = -1; src_step2_x =   1; src_step2_y = -ay; }
528   else if ((_ax < 0) && (_ay >= 0) && ((opcode & 0x0800) == 0x0800))
529      { src_step1_x =  0; src_step1_y =  1; src_step2_x =  -1; src_step2_y = -ay; }
530   else // ((_ax < 0) && (_ay < 0) && ((opcode & 0x0800) == 0x0800))
531      { src_step1_x =  0; src_step1_y = -1; src_step2_x =  -1; src_step2_y = -ay; }
532
533   for (;;)
534   {
535      for (;;)
536      {
537         dot(xxd,yyd,opcode & 0x0007,get_pixel(xxs,yys));
538
539         if (opcode & 0x0800)
540         {
541            if (ay == 0) break;
542            if (_ay > 0)
543            {
544               xxs += src_step1_x;
545               yys += src_step1_y;
546               xxd += dst_step1_x;
547               yyd += dst_step1_y;
548               ay--;
549            }
550            else
551            {
552               xxs += src_step1_x;
553               yys += src_step1_y;
554               xxd += dst_step1_x;
555               yyd += dst_step1_y;
556               ay++;
557            }
558         }
559         else
560         {
561            if (ax == 0) break;
562            else if (ax > 0)
563            {
564               xxs += src_step1_x;
565               yys += src_step1_y;
566               xxd += dst_step1_x;
567               yyd += dst_step1_y;
568               ax--;
569            }
570            else
571            {
572               xxs += src_step1_x;
573               yys += src_step1_y;
574               xxd += dst_step1_x;
575               yyd += dst_step1_y;
576               ax++;
577            }
578         }
579      }
580
581      if (opcode & 0x0800)
582      {
583         ay = _ay;
584         if (_ax < 0)
585         {
586            xxs += src_step2_x;
587            yys += src_step2_y;
588            xxd += dst_step2_x;
589            yyd += dst_step2_y;
590            if (ax == 0) break;
591            ax++;
592         }
593         else
594         {
595            xxs += src_step2_x;
596            yys += src_step2_y;
597            xxd += dst_step2_x;
598            yyd += dst_step2_y;
599            if (ax == 0) break;
600            ax--;
601         }
602      }
603      else
604      {
605         ax = _ax;
606         if (_ay < 0)
607         {
608            xxs += src_step2_x;
609            yys += src_step2_y;
610            xxd += dst_step2_x;
611            yyd += dst_step2_y;
612            if (ay == 0) break;
613            ay++;
614         }
615         else
616         {
617            xxs += src_step2_x;
618            yys += src_step2_y;
619            xxd += dst_step2_x;
620            yyd += dst_step2_y;
621            if (ay == 0) break;
622            ay--;
623         }
624      }
625   }
626}
627
628static void ptn(int opcode,int src_x,int src_y,INT16 _ax,INT16 _ay)
629{
630   int dst_step1_x = 0,dst_step1_y = 0,dst_step2_x = 0,dst_step2_y = 0;
631   int src_step1_x,src_step1_y,src_step2_x,src_step2_y;
632   int ax = _ax;
633   int ay = _ay;
634   int ax_neg,ay_neg;
635   int xxs = src_x;
636   int yys = src_y;
637   int xxd = cpx;
638   int yyd = cpy;
639   int getpixel;
640
641   if (ax < 0)
642      ax_neg = -1;
643   else
644      ax_neg = 1;
645   if (ay < 0)
646      ay_neg = -1;
647   else
648      ay_neg = 1;
649
650   if (opcode & 0x0800)
651      switch (opcode & 0x0700)
652      {
653         default:
654         case 0x0000: logerror("PTN: not supported"); break;
655         case 0x0100: logerror("PTN: not supported"); break;
656         case 0x0200: logerror("PTN: not supported"); break;
657         case 0x0300: logerror("PTN: not supported"); break;
658         case 0x0400: logerror("PTN: not supported"); break;
659         case 0x0500: logerror("PTN: not supported"); break;
660         case 0x0600: logerror("PTN: not supported"); break;
661         case 0x0700: logerror("PTN: not supported"); break;
662      }
663   else
664      switch (opcode & 0x0700)
665      {
666         default:
667         case 0x0000: dst_step1_x =  1; dst_step1_y =  0; dst_step2_x = -ax_neg*ax; dst_step2_y =  1; break;
668         case 0x0100: logerror("PTN: not supported"); break;
669         case 0x0200: dst_step1_x =  0; dst_step1_y =  1; dst_step2_x = -1; dst_step2_y = -ax_neg*ax; break;
670         case 0x0300: logerror("PTN: not supported"); break;
671         case 0x0400: dst_step1_x = -1; dst_step1_y =  0; dst_step2_x =  ax_neg*ax; dst_step2_y = -1; break;
672         case 0x0500: logerror("PTN: not supported"); break;
673         case 0x0600: dst_step1_x =  0; dst_step1_y = -1; dst_step2_x =  1; dst_step2_y =  ax_neg*ax; break;
674         case 0x0700: logerror("PTN: not supported"); break;
675      }
676
677   src_step1_x =  1; src_step1_y =  0; src_step2_x = -ax; src_step2_y =  1;
678
679   for (;;)
680   {
681      for (;;)
682      {
683         getpixel = get_pixel_ptn(xxs,yys);
684         switch ((opcode & 0x0018) >> 3)
685         {
686            case 0x0000:
687               if (getpixel)
688                  dot(xxd,yyd,opcode & 0x0007,cl1);
689               else
690                  dot(xxd,yyd,opcode & 0x0007,cl0);
691               break;
692            case 0x0001:
693               if (getpixel)
694                  dot(xxd,yyd,opcode & 0x0007,cl1);
695               break;
696            case 0x0002:
697               if (getpixel == 0)
698                  dot(xxd,yyd,opcode & 0x0007,cl0);
699               break;
700            case 0x0003:
701               logerror("PTN: not supported"); break;
702               break;
703         }
704
705         if (opcode & 0x0800)
706         {
707            if (ay == 0) break;
708            if (_ay > 0)
709            {
710               xxs += src_step1_x;
711               yys += src_step1_y;
712               xxd += dst_step1_x;
713               yyd += dst_step1_y;
714               ay--;
715            }
716            else
717            {
718               xxs += src_step1_x;
719               yys += src_step1_y;
720               xxd += dst_step1_x;
721               yyd += dst_step1_y;
722               ay++;
723            }
724         }
725         else
726         {
727            if (ax == 0) break;
728            else if (ax > 0)
729            {
730               xxs += src_step1_x;
731               yys += src_step1_y;
732               xxd += dst_step1_x;
733               yyd += dst_step1_y;
734               ax--;
735            }
736            else
737            {
738               xxs += src_step1_x;
739               yys += src_step1_y;
740               xxd += dst_step1_x;
741               yyd += dst_step1_y;
742               ax++;
743            }
744         }
745      }
746
747      if (opcode & 0x0800)
748      {
749         ay = _ay;
750         if (_ax < 0)
751         {
752            xxs += src_step2_x;
753            yys += src_step2_y;
754            xxd += dst_step2_x;
755            yyd += dst_step2_y;
756            if (ax == 0) break;
757            ax++;
758         }
759         else
760         {
761            xxs += src_step2_x;
762            yys += src_step2_y;
763            xxd += dst_step2_x;
764            yyd += dst_step2_y;
765            if (ax == 0) break;
766            ax--;
767         }
768      }
769      else
770      {
771         ax = _ax;
772         if (_ay < 0)
773         {
774            xxs += src_step2_x;
775            yys += src_step2_y;
776            xxd += dst_step2_x;
777            yyd += dst_step2_y;
778            if (ay == 0) break;
779            ay++;
780         }
781         else
782         {
783            xxs += src_step2_x;
784            yys += src_step2_y;
785            xxd += dst_step2_x;
786            yyd += dst_step2_y;
787            if (ay == 0) break;
788            ay--;
789         }
790      }
791   }
792}
793
794static void line(INT16 sx, INT16 sy, INT16 ex, INT16 ey, INT16 col)
795{
796         INT16 ax,ay;
797
798         int cpx_t=sx;
799         int cpy_t=sy;
800
801         ax = ex - sx;
802         ay = ey - sy;
803
804         if (abs(ax) >= abs(ay))
805         {
806            while (ax)
807            {
808               dot(cpx_t,cpy_t,col & 7,cl0);
809
810               if (ax > 0)
811               {
812                  cpx_t++;
813                  ax--;
814               }
815               else
816               {
817                  cpx_t--;
818                  ax++;
819               }
820               cpy_t = sy + ay * (cpx_t - sx) / (ex - sx);
821            }
822         }
823         else
824         {
825            while (ay)
826            {
827               dot(cpx_t,cpy_t,col & 7,cl0);
828
829               if (ay > 0)
830               {
831                  cpy_t++;
832                  ay--;
833               }
834               else
835               {
836                  cpy_t--;
837                  ay++;
838               }
839               cpx_t = sx + ax * (cpy_t - sy) / (ey - sy);
840            }
841         }
842
843}
844
845static void circle(INT16 sx, INT16 sy, UINT16 r, INT16 col)
846{
847   const float DEG2RAD = 3.14159f/180;
848   int i;
849   for (i = 0; i < 360 * (r / 10); i++)
850   {
851      float degInRad = i * DEG2RAD / (r / 10);
852      dot(sx + cos(degInRad) * r,sy + sin(degInRad) * r,col & 7,cl0);
853   }
854}
855
856static void paint(int sx, int sy, int col)
857{
858   int getpixel;
859   dot(sx,sy,0,col);
860
861   getpixel = get_pixel(sx+1,sy);
862   switch ((HD63484_reg[0x02/2] & 0x700) >> 8)
863   {
864      case 0:
865         break;
866      case 1:
867         break;
868      case 2:
869         getpixel = (getpixel << 12) | (getpixel << 8) | (getpixel << 4) | (getpixel << 0);
870         break;
871      case 3:
872         getpixel = (getpixel << 8) | (getpixel << 0);
873         break;
874      case 4:
875         break;
876
877      default:
878         logerror ("Graphic bit mode not supported\n");
879   }
880   if ((getpixel != col) && (getpixel != edg))
881      {
882         sx++;
883         paint(sx,sy,col);
884         sx--;
885      }
886
887   getpixel = get_pixel(sx-1,sy);
888   switch ((HD63484_reg[0x02/2] & 0x700) >> 8)
889   {
890      case 0:
891         break;
892      case 1:
893         break;
894      case 2:
895         getpixel = (getpixel << 12) | (getpixel << 8) | (getpixel << 4) | (getpixel << 0);
896         break;
897      case 3:
898         getpixel = (getpixel << 8) | (getpixel << 0);
899         break;
900      case 4:
901         break;
902
903      default:
904         logerror ("Graphic bit mode not supported\n");
905   }
906   if ((getpixel != col) && (getpixel != edg))
907      {
908         sx--;
909         paint(sx,sy,col);
910         sx++;
911      }
912
913   getpixel = get_pixel(sx,sy+1);
914   switch ((HD63484_reg[0x02/2] & 0x700) >> 8)
915   {
916      case 0:
917         break;
918      case 1:
919         break;
920      case 2:
921         getpixel = (getpixel << 12) | (getpixel << 8) | (getpixel << 4) | (getpixel << 0);
922         break;
923      case 3:
924         getpixel = (getpixel << 8) | (getpixel << 0);
925         break;
926      case 4:
927         break;
928
929      default:
930         logerror ("Graphic bit mode not supported\n");
931   }
932   if ((getpixel != col) && (getpixel != edg))
933      {
934         sy++;
935         paint(sx,sy,col);
936         sy--;
937      }
938
939   getpixel = get_pixel(sx,sy-1);
940   switch ((HD63484_reg[0x02/2] & 0x700) >> 8)
941   {
942      case 0:
943         break;
944      case 1:
945         break;
946      case 2:
947         getpixel = (getpixel << 12) | (getpixel << 8) | (getpixel << 4) | (getpixel << 0);
948         break;
949      case 3:
950         getpixel = (getpixel << 8) | (getpixel << 0);
951         break;
952      case 4:
953         break;
954
955      default:
956         logerror ("Graphic bit mode not supported\n");
957   }
958   if ((getpixel != col) && (getpixel != edg))
959      {
960         sy--;
961         paint(sx,sy,col);
962         sy++;
963      }
964}
965
966static void HD63484_command_w(running_machine *machine, UINT16 cmd)
967{
968   int len;
969
970   fifo[fifo_counter++] = cmd;
971
972   len = instruction_length[fifo[0]>>10];
973   if (len == -1)
974   {
975      if (fifo_counter < 2) return;
976      else len = fifo[1]+2;
977   }
978   else if (len == -2)
979   {
980      if (fifo_counter < 2) return;
981      else len = 2*fifo[1]+2;
982   }
983
984   if (fifo_counter >= len)
985   {
986#if LOG_COMMANDS
987      int i;
988
989      logerror("%s: HD63484 command %s (%04x) ",cpuexec_describe_context(machine),instruction_name[fifo[0]>>10],fifo[0]);
990      for (i = 1;i < fifo_counter;i++)
991         logerror("%04x ",fifo[i]);
992      logerror("\n");
993#endif
994
995      if (fifo[0] == 0x0400) { /* ORG */
996         org = ((fifo[1] & 0x00ff) << 12) | ((fifo[2] & 0xfff0) >> 4);
997         org_dpd = fifo[2] & 0x000f;
998      }
999      else if ((fifo[0] & 0xffe0) == 0x0800)   /* WPR */
1000      {
1001         if (fifo[0] == 0x0800)
1002            cl0 = fifo[1];
1003         else if (fifo[0] == 0x0801)
1004            cl1 = fifo[1];
1005         else if (fifo[0] == 0x0802)
1006            ccmp = fifo[1];
1007         else if (fifo[0] == 0x0803)
1008            edg = fifo[1];
1009         else if (fifo[0] == 0x0804)
1010            mask = fifo[1];
1011         else if (fifo[0] == 0x0805)
1012            {
1013               ppy  = (fifo[1] & 0xf000) >> 12;
1014               pzcy = (fifo[1] & 0x0f00) >> 8;
1015               ppx  = (fifo[1] & 0x00f0) >> 4;
1016               pzcx = (fifo[1] & 0x000f) >> 0;
1017            }
1018         else if (fifo[0] == 0x0806)
1019            {
1020               psy  = (fifo[1] & 0xf000) >> 12;
1021               psx  = (fifo[1] & 0x00f0) >> 4;
1022            }
1023         else if (fifo[0] == 0x0807)
1024            {
1025               pey  = (fifo[1] & 0xf000) >> 12;
1026               pzy  = (fifo[1] & 0x0f00) >> 8;
1027               pex  = (fifo[1] & 0x00f0) >> 4;
1028               pzx  = (fifo[1] & 0x000f) >> 0;
1029            }
1030         else if (fifo[0] == 0x0808)
1031            xmin = fifo[1];
1032         else if (fifo[0] == 0x0809)
1033            ymin = fifo[1];
1034         else if (fifo[0] == 0x080a)
1035            xmax = fifo[1];
1036         else if (fifo[0] == 0x080b)
1037            ymax = fifo[1];
1038         else if (fifo[0] == 0x080c)
1039            {
1040               rwp = (rwp & 0x00fff) | ((fifo[1] & 0x00ff) << 12);
1041               rwp_dn = (fifo[1] & 0xc000) >> 14;
1042            }
1043         else if (fifo[0] == 0x080d)
1044            {
1045               rwp = (rwp & 0xff000) | ((fifo[1] & 0xfff0) >> 4);
1046            }
1047         else
1048            logerror("unsupported register\n");
1049      }
1050      else if ((fifo[0] & 0xffe0) == 0x0c00)   /* RPR */
1051      {
1052         if (fifo[0] == 0x0c00)
1053            fifo[1] = cl0;
1054         else if (fifo[0] == 0x0c01)
1055            fifo[1] = cl1;
1056         else if (fifo[0] == 0x0c02)
1057            fifo[1] = ccmp;
1058         else if (fifo[0] == 0x0c03)
1059            fifo[1] = edg;
1060         else if (fifo[0] == 0x0c04)
1061            fifo[1] = mask;
1062         else if (fifo[0] == 0x0c05)
1063            {
1064               fifo[1] = (ppy << 12) | (pzcy << 8) | (ppx << 4) | pzcx;
1065            }
1066         else if (fifo[0] == 0x0c06)
1067            {
1068               fifo[1] = (psx << 12) | (psx << 4);
1069            }
1070         else if (fifo[0] == 0x0c07)
1071            {
1072               fifo[1] = (pey << 12) | (pzy << 8) | (pex << 4) | pzx;
1073            }
1074         else if (fifo[0] == 0x0c08)
1075            fifo[1] = xmin;
1076         else if (fifo[0] == 0x0c09)
1077            fifo[1] = ymin;
1078         else if (fifo[0] == 0x0c0a)
1079            fifo[1] = xmax;
1080         else if (fifo[0] == 0x0c0b)
1081            fifo[1] = ymax;
1082         else if (fifo[0] == 0x0c0c)
1083            {
1084               fifo[1] = (rwp_dn << 14) | ((rwp >> 12) & 0xff);
1085            }
1086         else if (fifo[0] == 0x0c0d)
1087            {
1088               fifo[1] = (rwp & 0x0fff) << 4;
1089            }
1090         else if (fifo[0] == 0x0c10)
1091            {
1092               // TODO
1093            }
1094         else if (fifo[0] == 0x0c11)
1095            {
1096               // TODO
1097            }
1098         else if (fifo[0] == 0x0c12)
1099            {
1100               fifo[1] = cpx;
1101            }
1102         else if (fifo[0] == 0x0c13)
1103            {
1104               fifo[1] = cpy;
1105            }
1106         else
1107            logerror("unsupported register\n");
1108      }
1109      else if ((fifo[0] & 0xfff0) == 0x1800)   /* WPTN */
1110      {
1111         int i;
1112         int start = fifo[0] & 0x000f;
1113         int n = fifo[1];
1114         for (i = 0; i < n; i++)
1115            pattern[start + i] = fifo[2 + i];
1116      }
1117      else if (fifo[0] == 0x4400)   /* RD */
1118      {
1119         readfifo = HD63484_ram[rwp];
1120         rwp = (rwp + 1) & (HD63484_RAM_SIZE-1);
1121      }
1122      else if (fifo[0] == 0x4800)   /* WT */
1123      {
1124         HD63484_ram[rwp] = fifo[1];
1125         rwp = (rwp + 1) & (HD63484_RAM_SIZE-1);
1126      }
1127      else if (fifo[0] == 0x5800)   /* CLR */
1128      {
1129         doclr16(fifo[0],fifo[1],&rwp,fifo[2],fifo[3]);
1130
1131            {
1132                int fifo2 = (int)fifo[2],fifo3 = (int)fifo[3];
1133                if (fifo2<0) fifo2 *= -1;
1134                if (fifo3<0) fifo3 *= -1;
1135                rwp += ((fifo2+1)*(fifo3+1));
1136            }
1137
1138      }
1139      else if ((fifo[0] & 0xfffc) == 0x5c00)   /* SCLR */
1140      {
1141         doclr16(fifo[0],fifo[1],&rwp,fifo[2],fifo[3]);
1142
1143            {
1144                int fifo2 = (int)fifo[2],fifo3 = (int)fifo[3];
1145                if (fifo2<0) fifo2 *= -1;
1146                if (fifo3<0) fifo3 *= -1;
1147                rwp += ((fifo2+1)*(fifo3+1));
1148            }
1149
1150      }
1151      else if ((fifo[0] & 0xf0ff) == 0x6000)   /* CPY */
1152      {
1153         docpy16(fifo[0],((fifo[1] & 0x00ff) << 12) | ((fifo[2] & 0xfff0) >> 4),&rwp,fifo[3],fifo[4]);
1154
1155            {
1156                int fifo2 = (int)fifo[2],fifo3 = (int)fifo[3];
1157                if (fifo2<0) fifo2 *= -1;
1158                if (fifo3<0) fifo3 *= -1;
1159                rwp += ((fifo2+1)*(fifo3+1));
1160            }
1161
1162      }
1163      else if ((fifo[0] & 0xf0fc) == 0x7000)   /* SCPY */
1164      {
1165         docpy16(fifo[0],((fifo[1] & 0x00ff) << 12) | ((fifo[2] & 0xfff0) >> 4),&rwp,fifo[3],fifo[4]);
1166
1167            {
1168                int fifo2 = (int)fifo[2],fifo3 = (int)fifo[3];
1169                if (fifo2<0) fifo2 *= -1;
1170                if (fifo3<0) fifo3 *= -1;
1171                rwp += ((fifo2+1)*(fifo3+1));
1172            }
1173
1174      }
1175      else if (fifo[0] == 0x8000)   /* AMOVE */
1176      {
1177         cpx = fifo[1];
1178         cpy = fifo[2];
1179      }
1180      else if (fifo[0] == 0x8400)   /* RMOVE */
1181      {
1182         cpx += (INT16)fifo[1];
1183         cpy += (INT16)fifo[2];
1184      }
1185      else if ((fifo[0] & 0xff00) == 0x8800)   /* ALINE */
1186      {
1187         line(cpx,cpy,fifo[1],fifo[2],fifo[0] & 0xff);
1188         cpx = (INT16)fifo[1];
1189         cpy = (INT16)fifo[2];
1190      }
1191      else if ((fifo[0] & 0xff00) == 0x8c00)   /* RLINE */
1192      {
1193         line(cpx,cpy,cpx+(INT16)fifo[1],cpy+(INT16)fifo[2],fifo[0] & 0xff);
1194         cpx += (INT16)fifo[1];
1195         cpy += (INT16)fifo[2];
1196      }
1197      else if ((fifo[0] & 0xfff8) == 0x9000)   /* ARCT */
1198      {
1199         line(cpx,cpy,(INT16)fifo[1],cpy,fifo[0] & 0xff);
1200         line((INT16)fifo[1],cpy,(INT16)fifo[1],(INT16)fifo[2],fifo[0] & 0xff);
1201         line((INT16)fifo[1],(INT16)fifo[2],cpx,(INT16)fifo[2],fifo[0] & 0xff);
1202         line(cpx,(INT16)fifo[2],cpx,cpy,fifo[0] & 0xff);
1203         cpx = (INT16)fifo[1];
1204         cpy = (INT16)fifo[2];
1205      }
1206      else if ((fifo[0] & 0xfff8) == 0x9400)   /* RRCT  added*/
1207      {
1208         line(cpx,cpy,cpx+(INT16)fifo[1],cpy,fifo[0] & 0xff);
1209         line(cpx+(INT16)fifo[1],cpy,cpx+(INT16)fifo[1],cpy+(INT16)fifo[2],fifo[0] & 0xff);
1210         line(cpx+(INT16)fifo[1],cpy+(INT16)fifo[2],cpx,cpy+(INT16)fifo[2],fifo[0] & 0xff);
1211         line(cpx,cpy+(INT16)fifo[2],cpx,cpy,fifo[0] & 0xff);
1212
1213         cpx += (INT16)fifo[1];
1214         cpy += (INT16)fifo[2];
1215      }
1216      else if ((fifo[0] & 0xfff8) == 0xa400)   /* RPLG  added*/
1217      {
1218         int nseg,sx,sy,ex,ey;
1219         sx = cpx;
1220         sy = cpy;
1221         for(nseg=0;nseg<fifo[1];nseg++)
1222         {
1223            ex = sx + (INT16)fifo[2+nseg*2];
1224            ey = sy + (INT16)fifo[2+nseg*2+1];
1225            line(sx,sy,ex,ey,fifo[0]&7);
1226            sx = ex;
1227            sy = ey;
1228         }
1229         line(sx,sy,cpx,cpy,fifo[0]&7);
1230      }
1231      else if ((fifo[0] & 0xfe00) == 0xa800)   /* CRCL  added*/
1232      {
1233         circle(cpx,cpy,fifo[1] & 0x1fff,fifo[0]&7); // only 13 bit are used for the radius
1234      }
1235      else if ((fifo[0] & 0xfff8) == 0xc000)   /* AFRCT */
1236      {
1237         INT16 pcx,pcy;
1238         INT16 ax,ay,xx,yy;
1239
1240
1241         pcx = fifo[1];
1242         pcy = fifo[2];
1243         ax = pcx - cpx;
1244         ay = pcy - cpy;
1245         xx = cpx;
1246         yy = cpy;
1247
1248         for (;;)
1249         {
1250            for (;;)
1251            {
1252               dot(xx,yy,fifo[0] & 0x07,cl0);
1253
1254               if (ax == 0) break;
1255               else if (ax > 0)
1256               {
1257                  xx++;
1258                  ax--;
1259               }
1260               else
1261               {
1262                  xx--;
1263                  ax++;
1264               }
1265            }
1266
1267            ax = pcx - cpx;
1268            if (pcy < cpy)
1269            {
1270               yy--;
1271               xx -= ax;
1272               if (ay == 0) break;
1273               ay++;
1274            }
1275            else
1276            {
1277               yy++;
1278               xx -= ax;
1279               if (ay == 0) break;
1280               ay--;
1281            }
1282         }
1283      }
1284      else if ((fifo[0] & 0xfff8) == 0xc400)   /* RFRCT  added TODO*/
1285      {
1286         line(cpx,cpy,cpx+(INT16)fifo[1],cpy,fifo[0] & 0xff);
1287         line(cpx+fifo[1],cpy,cpx+fifo[1],cpy+fifo[2],fifo[0] & 0xff);
1288         line(cpx+fifo[1],cpy+fifo[2],cpx,cpy+fifo[2],fifo[0] & 0xff);
1289         line(cpx,cpy+fifo[2],cpx,cpy,fifo[0] & 0xff);
1290
1291         cpx=cpx+(INT16)fifo[1];
1292         cpy=cpy+(INT16)fifo[2];
1293      }
1294      else if (fifo[0] == 0xc800)   /* PAINT */
1295      {
1296         paint(cpx,cpy,cl0);
1297      }
1298      else if ((fifo[0] & 0xfff8) == 0xcc00)   /* DOT */
1299      {
1300         dot(cpx,cpy,fifo[0] & 0xff,cl0);
1301      }
1302      else if ((fifo[0] & 0xf000) == 0xd000)   /* PTN (to do) */
1303      {
1304         ptn(fifo[0],psx,psy,pex - psx,pey - psy);
1305
1306         if ((fifo[0] & 0x0800) == 0x0000)
1307            switch (fifo[0] & 0x0700)
1308            {
1309               case 0x0000:
1310                  if ((pey - psy) > 0)
1311                     cpy += (pey - psy);
1312                  else
1313                     cpy -= (pey - psy);
1314                  break;
1315               case 0x0100:
1316                  // missing
1317                  break;
1318               case 0x0200:
1319                  if ((pey - psy) > 0)
1320                     cpx += (pey - psy);
1321                  else
1322                     cpx -= (pey - psy);
1323                  break;
1324               case 0x0300:
1325                  // missing
1326                  break;
1327               case 0x0400:
1328                  if ((pey - psy) > 0)
1329                     cpy -= (pey - psy);
1330                  else
1331                     cpy += (pey - psy);
1332                  break;
1333               case 0x0500:
1334                  // missing
1335                  break;
1336               case 0x0600:
1337                  if ((pey - psy) > 0)
1338                     cpx -= (pey - psy);
1339                  else
1340                     cpx += (pey - psy);
1341                  break;
1342               case 0x0700:
1343                  // missing
1344                  break;
1345            }
1346         else
1347            {
1348               // missing
1349            }
1350      }
1351      else if ((fifo[0] & 0xf018) == 0xe000)   /* AGCPY */
1352      {
1353         agcpy(fifo[0],(INT16)fifo[1],(INT16)fifo[2],cpx,cpy,fifo[3],fifo[4]);
1354
1355         switch (fifo[0] & 0x0700)
1356         {
1357            case 0x0000:
1358               if (fifo[4] > 0)
1359                  cpy += fifo[4];
1360               else
1361                  cpy -= fifo[4];
1362               break;
1363            case 0x0100:
1364               if (fifo[4] > 0)
1365                  cpy -= fifo[4];
1366               else
1367                  cpy += fifo[4];
1368               break;
1369            case 0x0200:
1370               if (fifo[4] > 0)
1371                  cpy += fifo[4];
1372               else
1373                  cpy -= fifo[4];
1374               break;
1375            case 0x0300:
1376               if (fifo[4] > 0)
1377                  cpy -= fifo[4];
1378               else
1379                  cpy += fifo[4];
1380               break;
1381            case 0x0400:
1382               if (fifo[3] > 0)
1383                  cpx += fifo[3];
1384               else
1385                  cpx -= fifo[3];
1386               break;
1387            case 0x0500:
1388               if (fifo[3] > 0)
1389                  cpx += fifo[3];
1390               else
1391                  cpx -= fifo[3];
1392               break;
1393            case 0x0600:
1394               if (fifo[3] > 0)
1395                  cpx -= fifo[3];
1396               else
1397                  cpx += fifo[3];
1398               break;
1399            case 0x0700:
1400               if (fifo[3] > 0)
1401                  cpx -= fifo[3];
1402               else
1403                  cpx += fifo[3];
1404               break;
1405         }
1406      }
1407      else
1408         {
1409            logerror("unsupported command\n");
1410            popmessage("unsupported command %s (%04x)",instruction_name[fifo[0]>>10],fifo[0]);
1411         }
1412
1413      fifo_counter = 0;
1414   }
1415}
1416
1417static int regno;
1418
1419READ16_HANDLER( HD63484_status_r )
1420{
1421//  if (cpu_get_pc(space->cpu) != 0xfced6 && cpu_get_pc(space->cpu) != 0xfe1d6)
1422//      logerror("%05x: HD63484 status read\n",cpu_get_pc(space->cpu));
1423
1424   return 0xff22|(mame_rand(space->machine) & 0x0004);   /* write FIFO ready + command end    +  (read FIFO ready or read FIFO not ready) */
1425}
1426
1427WRITE16_HANDLER( HD63484_address_w )
1428{
1429   /* only low 8 bits are used */
1430   if (ACCESSING_BITS_0_7)
1431      regno = data;
1432}
1433
1434WRITE16_HANDLER( HD63484_data_w )
1435{
1436   COMBINE_DATA(&HD63484_reg[regno/2]);
1437
1438   if ( !strcmp(space->machine->gamedrv->name, "skattva")) HD63484_reg[2/2] = (HD63484_reg[2/2] & 0xf8ff) | 0x0200; // hack to set proper color depth in skattva
1439
1440   if (regno & 0x80) regno += 2;   /* autoincrement */
1441
1442#if LOG_COMMANDS
1443   logerror("PC %05x: HD63484 register %02x write %04x\n",cpu_get_pc(space->cpu),regno,HD63484_reg[regno/2]);
1444#endif
1445
1446   if (regno == 0)   /* FIFO */
1447      HD63484_command_w(space->machine, HD63484_reg[0]);
1448}
1449
1450READ16_HANDLER( HD63484_data_r )
1451{
1452   int res;
1453
1454   if (regno == 0x80)
1455      res = video_screen_get_vpos(space->machine->primary_screen);
1456   else if (regno == 0)
1457   {
1458#if LOG_COMMANDS
1459      logerror("%05x: HD63484 read FIFO\n",cpu_get_pc(space->cpu));
1460#endif
1461      res = readfifo;
1462   }
1463   else
1464   {
1465#if LOG_COMMANDS
1466      logerror("%05x: HD63484 read register %02x\n",cpu_get_pc(space->cpu),regno);
1467#endif
1468      res = 0;
1469   }
1470
1471   return res;
1472}
src/mame/video/hd63484.h
r7482r7483
1#define HD63484_RAM_SIZE 0x100000
2
3extern UINT16 *HD63484_ram;
4extern UINT16 HD63484_reg[256/2];
5
6void HD63484_start(running_machine *machine);
7
8READ16_HANDLER( HD63484_status_r );
9WRITE16_HANDLER( HD63484_address_w );
10WRITE16_HANDLER( HD63484_data_w );
11READ16_HANDLER( HD63484_data_r );
src/mame/video/ddrible.c
r7482r7483
1/***************************************************************************
2
3  video.c
4
5  Functions to emulate the video hardware of the machine.
6
7***************************************************************************/
8
9#include "emu.h"
10#include "includes/ddrible.h"
11
12
13PALETTE_INIT( ddrible )
14{
15   int i;
16
17   /* allocate the colortable */
18   machine->colortable = colortable_alloc(machine, 0x40);
19
20   for (i = 0x10; i < 0x40; i++)
21      colortable_entry_set_value(machine->colortable, i, i);
22
23   /* sprite #2 uses pens 0x00-0x0f */
24   for (i = 0x40; i < 0x140; i++)
25   {
26      UINT8 ctabentry = color_prom[i - 0x40] & 0x0f;
27      colortable_entry_set_value(machine->colortable, i, ctabentry);
28   }
29}
30
31
32static void set_pens( running_machine *machine )
33{
34   ddrible_state *state = (ddrible_state *)machine->driver_data;
35   int i;
36
37   for (i = 0x00; i < 0x80; i += 2)
38   {
39      UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8);
40
41      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
42      colortable_palette_set_color(machine->colortable, i >> 1, color);
43   }
44}
45
46
47WRITE8_HANDLER( K005885_0_w )
48{
49   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
50   switch (offset)
51   {
52      case 0x03:   /* char bank selection for set 1 */
53         if ((data & 0x03) != state->charbank[0])
54         {
55            state->charbank[0] = data & 0x03;
56            tilemap_mark_all_tiles_dirty(state->fg_tilemap);
57         }
58         break;
59      case 0x04:   /* IRQ control, flipscreen */
60         state->int_enable_0 = data & 0x02;
61         break;
62   }
63   state->vregs[0][offset] = data;
64}
65
66WRITE8_HANDLER( K005885_1_w )
67{
68   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
69   switch (offset)
70   {
71      case 0x03:   /* char bank selection for set 2 */
72         if ((data & 0x03) != state->charbank[1])
73         {
74            state->charbank[1] = data & 0x03;
75            tilemap_mark_all_tiles_dirty(state->bg_tilemap);
76         }
77         break;
78      case 0x04:   /* IRQ control, flipscreen */
79         state->int_enable_1 = data & 0x02;
80         break;
81   }
82   state->vregs[1][offset] = data;
83}
84
85/***************************************************************************
86
87    Callbacks for the TileMap code
88
89***************************************************************************/
90
91static TILEMAP_MAPPER( tilemap_scan )
92{
93   /* logical (col,row) -> memory offset */
94   return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x20) << 6);   /* skip 0x400 */
95}
96
97static TILE_GET_INFO( get_fg_tile_info )
98{
99   ddrible_state *state = (ddrible_state *)machine->driver_data;
100   UINT8 attr = state->fg_videoram[tile_index];
101   int num = state->fg_videoram[tile_index + 0x400] + ((attr & 0xc0) << 2) + ((attr & 0x20) << 5) + ((state->charbank[0] & 2) << 10);
102   SET_TILE_INFO(
103         0,
104         num,
105         0,
106         TILE_FLIPYX((attr & 0x30) >> 4));
107}
108
109static TILE_GET_INFO( get_bg_tile_info )
110{
111   ddrible_state *state = (ddrible_state *)machine->driver_data;
112   UINT8 attr = state->bg_videoram[tile_index];
113   int num = state->bg_videoram[tile_index + 0x400] + ((attr & 0xc0) << 2) + ((attr & 0x20) << 5) + (state->charbank[1] << 11);
114   SET_TILE_INFO(
115         1,
116         num,
117         0,
118         TILE_FLIPYX((attr & 0x30) >> 4));
119}
120
121/***************************************************************************
122
123    Start the video hardware emulation.
124
125***************************************************************************/
126
127VIDEO_START( ddrible )
128{
129   ddrible_state *state = (ddrible_state *)machine->driver_data;
130
131   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan, 8, 8, 64, 32);
132   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan, 8, 8, 64, 32);
133
134   tilemap_set_transparent_pen(state->fg_tilemap, 0);
135}
136
137/***************************************************************************
138
139    Memory handlers
140
141***************************************************************************/
142
143WRITE8_HANDLER( ddrible_fg_videoram_w )
144{
145   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
146   state->fg_videoram[offset] = data;
147   tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0xbff);
148}
149
150WRITE8_HANDLER( ddrible_bg_videoram_w )
151{
152   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
153   state->bg_videoram[offset] = data;
154   tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0xbff);
155}
156
157/***************************************************************************
158
159    Double Dribble sprites
160
161Each sprite has 5 bytes:
162byte #0:    sprite number
163byte #1:
164    bits 0..2:  sprite bank #
165    bit 3:      not used?
166    bits 4..7:  sprite color
167byte #2:    y position
168byte #3:    x position
169byte #4:    attributes
170    bit 0:      x position (high bit)
171    bit 1:      ???
172    bits 2..4:  sprite size
173    bit 5:      flip x
174    bit 6:      flip y
175    bit 7:      unused?
176
177***************************************************************************/
178
179static void draw_sprites( running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8* source, int lenght, int gfxset, int flipscreen )
180{
181   gfx_element *gfx = machine->gfx[gfxset];
182   const UINT8 *finish = source + lenght;
183
184   while (source < finish)
185   {
186      int number = source[0] | ((source[1] & 0x07) << 8);   /* sprite number */
187      int attr = source[4];                        /* attributes */
188      int sx = source[3] | ((attr & 0x01) << 8);         /* vertical position */
189      int sy = source[2];                           /* horizontal position */
190      int flipx = attr & 0x20;                     /* flip x */
191      int flipy = attr & 0x40;                     /* flip y */
192      int color = (source[1] & 0xf0) >> 4;            /* color */
193      int width, height;
194
195      if (flipscreen)
196      {
197         flipx = !flipx;
198         flipy = !flipy;
199         sx = 240 - sx;
200         sy = 240 - sy;
201
202         if ((attr & 0x1c) == 0x10)
203         {   /* ???. needed for some sprites in flipped mode */
204            sx -= 0x10;
205            sy -= 0x10;
206         }
207      }
208
209      switch (attr & 0x1c)
210      {
211         case 0x10:   /* 32x32 */
212            width = height = 2; number &= (~3); break;
213         case 0x08:   /* 16x32 */
214            width = 1; height = 2; number &= (~2); break;
215         case 0x04:   /* 32x16 */
216            width = 2; height = 1; number &= (~1); break;
217         /* the hardware allow more sprite sizes, but ddribble doesn't use them */
218         default:   /* 16x16 */
219            width = height = 1; break;
220      }
221
222      {
223         static const int x_offset[2] = { 0x00, 0x01 };
224         static const int y_offset[2] = { 0x00, 0x02 };
225         int x, y, ex, ey;
226
227         for (y = 0; y < height; y++)
228         {
229            for (x = 0; x < width; x++)
230            {
231               ex = flipx ? (width - 1 - x) : x;
232               ey = flipy ? (height - 1 - y) : y;
233
234               drawgfx_transpen(bitmap,cliprect,
235                  gfx,
236                  (number)+x_offset[ex]+y_offset[ey],
237                  color,
238                  flipx, flipy,
239                  sx+x*16,sy+y*16, 0);
240            }
241         }
242      }
243      source += 5;
244   }
245}
246
247/***************************************************************************
248
249    Display Refresh
250
251***************************************************************************/
252
253VIDEO_UPDATE( ddrible )
254{
255   ddrible_state *state = (ddrible_state *)screen->machine->driver_data;
256   set_pens(screen->machine);
257
258   tilemap_set_flip(state->fg_tilemap, (state->vregs[0][4] & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
259   tilemap_set_flip(state->bg_tilemap, (state->vregs[1][4] & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
260
261   /* set scroll registers */
262   tilemap_set_scrollx(state->fg_tilemap, 0, state->vregs[0][1] | ((state->vregs[0][2] & 0x01) << 8));
263   tilemap_set_scrollx(state->bg_tilemap, 0, state->vregs[1][1] | ((state->vregs[1][2] & 0x01) << 8));
264   tilemap_set_scrolly(state->fg_tilemap, 0, state->vregs[0][0]);
265   tilemap_set_scrolly(state->bg_tilemap, 0, state->vregs[1][0]);
266
267   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
268   draw_sprites(screen->machine, bitmap, cliprect, state->spriteram_1, 0x07d, 2, state->vregs[0][4] & 0x08);
269   draw_sprites(screen->machine, bitmap, cliprect, state->spriteram_2, 0x140, 3, state->vregs[1][4] & 0x08);
270   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
271   return 0;
272}
src/mame/video/sys16spr.c
r7482r7483
1/* sys16spr.c
2 old file, delete me
3*/
src/mame/drivers/ddrible.c
r7482r7483
1/***************************************************************************
2
3    Double Dribble (GX690) (c) Konami 1986
4
5    Driver by Manuel Abadia <manu@teleline.es>
6
7    2008-08
8    Dip locations and suggested settings verified with US manual.
9
10***************************************************************************/
11
12#include "emu.h"
13#include "cpu/m6809/m6809.h"
14#include "sound/2203intf.h"
15#include "sound/vlm5030.h"
16#include "sound/flt_rc.h"
17#include "includes/konamipt.h"
18#include "includes/ddrible.h"
19
20
21static INTERRUPT_GEN( ddrible_interrupt_0 )
22{
23   ddrible_state *state = (ddrible_state *)device->machine->driver_data;
24   if (state->int_enable_0)
25      cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE);
26}
27
28static INTERRUPT_GEN( ddrible_interrupt_1 )
29{
30   ddrible_state *state = (ddrible_state *)device->machine->driver_data;
31   if (state->int_enable_1)
32      cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE);
33}
34
35
36static WRITE8_HANDLER( ddrible_bankswitch_w )
37{
38   memory_set_bank(space->machine, "bank1", data & 0x0f);
39}
40
41
42static READ8_HANDLER( ddrible_sharedram_r )
43{
44   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
45   return state->sharedram[offset];
46}
47
48static WRITE8_HANDLER( ddrible_sharedram_w )
49{
50   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
51   state->sharedram[offset] = data;
52}
53
54static READ8_HANDLER( ddrible_snd_sharedram_r )
55{
56   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
57   return state->snd_sharedram[offset];
58}
59
60static WRITE8_HANDLER( ddrible_snd_sharedram_w )
61{
62   ddrible_state *state = (ddrible_state *)space->machine->driver_data;
63   state->snd_sharedram[offset] = data;
64}
65
66static WRITE8_HANDLER( ddrible_coin_counter_w )
67{
68   /* b4-b7: unused */
69   /* b2-b3: unknown */
70   /* b1: coin counter 2 */
71   /* b0: coin counter 1 */
72   coin_counter_w(space->machine, 0,(data) & 0x01);
73   coin_counter_w(space->machine, 1,(data >> 1) & 0x01);
74}
75
76static READ8_DEVICE_HANDLER( ddrible_vlm5030_busy_r )
77{
78   return mame_rand(device->machine); /* patch */
79   /* FIXME: remove ? */
80#if 0
81   if (vlm5030_bsy(device)) return 1;
82   else return 0;
83#endif
84}
85
86static WRITE8_DEVICE_HANDLER( ddrible_vlm5030_ctrl_w )
87{
88   ddrible_state *state = (ddrible_state *)device->machine->driver_data;
89   UINT8 *SPEECH_ROM = memory_region(device->machine, "vlm");
90
91   /* b7 : vlm data bus OE   */
92
93   /* b6 : VLM5030-RST       */
94   vlm5030_rst(device, data & 0x40 ? 1 : 0);
95
96   /* b5 : VLM5030-ST        */
97   vlm5030_st(device, data & 0x20 ? 1 : 0);
98
99   /* b4 : VLM5300-VCU       */
100   vlm5030_vcu(device, data & 0x10 ? 1 : 0);
101
102   /* b3 : ROM bank select   */
103   vlm5030_set_rom(device, &SPEECH_ROM[data & 0x08 ? 0x10000 : 0]);
104
105   /* b2 : SSG-C rc filter enable */
106   filter_rc_set_RC(state->filter3, FLT_RC_LOWPASS, 1000, 2200, 1000, data & 0x04 ? CAP_N(150) : 0); /* YM2203-SSG-C */
107
108   /* b1 : SSG-B rc filter enable */
109   filter_rc_set_RC(state->filter2, FLT_RC_LOWPASS, 1000, 2200, 1000, data & 0x02 ? CAP_N(150) : 0); /* YM2203-SSG-B */
110
111   /* b0 : SSG-A rc filter enable */
112   filter_rc_set_RC(state->filter1, FLT_RC_LOWPASS, 1000, 2200, 1000, data & 0x01 ? CAP_N(150) : 0); /* YM2203-SSG-A */
113}
114
115
116static ADDRESS_MAP_START( cpu0_map, ADDRESS_SPACE_PROGRAM, 8 )
117   AM_RANGE(0x0000, 0x0004) AM_WRITE(K005885_0_w)                                    /* video registers (005885 #1) */
118   AM_RANGE(0x0800, 0x0804) AM_WRITE(K005885_1_w)                                    /* video registers (005885 #2) */
119   AM_RANGE(0x1800, 0x187f) AM_RAM AM_BASE_MEMBER(ddrible_state, paletteram)                              /* palette */
120   AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(ddrible_fg_videoram_w) AM_BASE_MEMBER(ddrible_state, fg_videoram)   /* Video RAM 1 */
121   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_MEMBER(ddrible_state, spriteram_1)                        /* Object RAM 1 */
122   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(ddrible_state, sharedram)                           /* shared RAM with CPU #1 */
123   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(ddrible_bg_videoram_w) AM_BASE_MEMBER(ddrible_state, bg_videoram)   /* Video RAM 2 */
124   AM_RANGE(0x7000, 0x7fff) AM_RAM AM_BASE_MEMBER(ddrible_state, spriteram_2)                        /* Object RAM 2 */
125   AM_RANGE(0x8000, 0x8000) AM_WRITE(ddrible_bankswitch_w)                              /* bankswitch control */
126   AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("bank1")                                          /* banked ROM */
127   AM_RANGE(0xa000, 0xffff) AM_ROM                                                /* ROM */
128ADDRESS_MAP_END
129
130static ADDRESS_MAP_START( cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
131   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(ddrible_sharedram_r, ddrible_sharedram_w)         /* shared RAM with CPU #0 */
132   AM_RANGE(0x2000, 0x27ff) AM_READWRITE(ddrible_snd_sharedram_r, ddrible_snd_sharedram_w)   /* shared RAM with CPU #2 */
133   AM_RANGE(0x2800, 0x2800) AM_READ_PORT("DSW1")
134   AM_RANGE(0x2801, 0x2801) AM_READ_PORT("P1")
135   AM_RANGE(0x2802, 0x2802) AM_READ_PORT("P2")
136   AM_RANGE(0x2803, 0x2803) AM_READ_PORT("SYSTEM")                                 /* coinsw & start */
137   AM_RANGE(0x2c00, 0x2c00) AM_READ_PORT("DSW2")
138   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("DSW3")
139   AM_RANGE(0x3400, 0x3400) AM_WRITE(ddrible_coin_counter_w)                        /* coin counters */
140   AM_RANGE(0x3c00, 0x3c00) AM_WRITE(watchdog_reset_w)                              /* watchdog reset */
141   AM_RANGE(0x8000, 0xffff) AM_ROM                                             /* ROM */
142ADDRESS_MAP_END
143
144static ADDRESS_MAP_START( cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )
145   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(ddrible_state, snd_sharedram)      /* shared RAM with CPU #1 */
146   AM_RANGE(0x1000, 0x1001) AM_DEVREADWRITE("ymsnd", ym2203_r, ym2203_w)   /* YM2203 */
147   AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("vlm", vlm5030_data_w)         /* Speech data */
148   AM_RANGE(0x8000, 0xffff) AM_ROM                              /* ROM */
149ADDRESS_MAP_END
150
151static INPUT_PORTS_START( ddribble )
152   PORT_START("P1")
153   KONAMI8_B132(1)
154   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
155
156   PORT_START("P2")
157   KONAMI8_B132(2)
158   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
159
160   PORT_START("SYSTEM")
161   KONAMI8_SYSTEM_UNK
162
163   PORT_START("DSW1")
164   KONAMI_COINAGE_ALT_LOC(SW1)
165
166   PORT_START("DSW2")
167   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x00, "SW2:1" )   /* Manual says it's Unused */
168   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x00, "SW2:2" )   /* Manual says it's Unused */
169   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
170   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
171   PORT_DIPSETTING(   0x04, DEF_STR( Cocktail ) )
172   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x00, "SW2:4" )   /* Manual says it's Unused */
173   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x00, "SW2:5" )   /* Manual says it's Unused */
174   PORT_DIPNAME( 0x60, 0x20, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:6,7")
175   PORT_DIPSETTING(   0x60, DEF_STR( Easy ) )
176   PORT_DIPSETTING(   0x40, DEF_STR( Normal ) )
177   PORT_DIPSETTING(   0x20, DEF_STR( Hard ) )
178   PORT_DIPSETTING(   0x00, DEF_STR( Hardest ) )
179   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
180   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
181   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
182
183   PORT_START("DSW3")
184   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW3:1")
185   PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
186   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
187   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x00, "SW3:2" )   /* Manual says it's Unused */
188   PORT_SERVICE_DIPLOC( 0x04, IP_ACTIVE_LOW, "SW3:3" )
189   PORT_DIPNAME( 0x08, 0x08, "Allow vs match with 1 Credit" ) PORT_DIPLOCATION("SW3:4")
190   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
191   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
192   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
193   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
194   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
195   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
196INPUT_PORTS_END
197
198
199
200static const gfx_layout charlayout =
201{
202   8,8,
203   RGN_FRAC(1,2),
204   4,
205   { 0, 1, 2, 3 },
206   { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 },
207   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
208   32*8
209};
210
211static const gfx_layout spritelayout =
212{
213   16,16,
214   RGN_FRAC(1,2),
215   4,
216   { 0, 1, 2, 3 },
217   { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4,
218         32*8+0*4, 32*8+1*4, 32*8+2*4, 32*8+3*4, 32*8+4*4, 32*8+5*4, 32*8+6*4, 32*8+7*4 },
219   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
220         16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
221   32*32
222};
223
224static GFXDECODE_START( ddrible )
225   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout,    48,  1 )   /* colors 48-63 */
226   GFXDECODE_ENTRY( "gfx2", 0x00000, charlayout,    16,  1 )   /* colors 16-31 */
227   GFXDECODE_ENTRY( "gfx1", 0x20000, spritelayout,  32,  1 )   /* colors 32-47 */
228   GFXDECODE_ENTRY( "gfx2", 0x40000, spritelayout,  64, 16 )   /* colors  0-15 but using lookup table */
229GFXDECODE_END
230
231static const ym2203_interface ym2203_config =
232{
233   {
234      AY8910_LEGACY_OUTPUT,
235      AY8910_DEFAULT_LOADS,
236      DEVCB_NULL,
237      DEVCB_DEVICE_HANDLER("vlm", ddrible_vlm5030_busy_r),
238      DEVCB_DEVICE_HANDLER("vlm", ddrible_vlm5030_ctrl_w),
239      DEVCB_NULL
240   },
241   NULL
242};
243
244static const vlm5030_interface vlm5030_config =
245{
246   0x10000     /* memory size 64Kbyte * 2 bank */
247};
248
249
250
251static MACHINE_START( ddrible )
252{
253   ddrible_state *state = (ddrible_state *)machine->driver_data;
254   UINT8 *ROM = memory_region(machine, "maincpu");
255   memory_configure_bank(machine, "bank1", 0, 5, &ROM[0x10000], 0x2000);
256
257   state->filter1 = devtag_get_device(machine, "filter1");
258   state->filter2 = devtag_get_device(machine, "filter2");
259   state->filter3 = devtag_get_device(machine, "filter3");
260
261   state_save_register_global(machine, state->int_enable_0);
262   state_save_register_global(machine, state->int_enable_1);
263   state_save_register_global_array(machine, state->vregs[0]);
264   state_save_register_global_array(machine, state->vregs[1]);
265   state_save_register_global_array(machine, state->charbank);
266}
267
268static MACHINE_RESET( ddrible )
269{
270   ddrible_state *state = (ddrible_state *)machine->driver_data;
271   int i;
272
273   for (i = 0; i < 5; i++)
274   {
275      state->vregs[0][i] = 0;
276      state->vregs[1][i] = 0;
277   }
278
279   state->int_enable_0 = 0;
280   state->int_enable_1 = 0;
281   state->charbank[0] = 0;
282   state->charbank[1] = 0;
283}
284
285static MACHINE_DRIVER_START( ddribble )
286
287   /* driver data */
288   MDRV_DRIVER_DATA(ddrible_state)
289
290   /* basic machine hardware */
291   MDRV_CPU_ADD("maincpu", M6809,   XTAL_18_432MHz/12)   /* verified on pcb */
292   MDRV_CPU_PROGRAM_MAP(cpu0_map)
293   MDRV_CPU_VBLANK_INT("screen", ddrible_interrupt_0)
294
295   MDRV_CPU_ADD("cpu1", M6809,   XTAL_18_432MHz/12)   /* verified on pcb */
296   MDRV_CPU_PROGRAM_MAP(cpu1_map)
297   MDRV_CPU_VBLANK_INT("screen", ddrible_interrupt_1)
298
299   MDRV_CPU_ADD("cpu2", M6809,   XTAL_18_432MHz/12)   /* verified on pcb */
300   MDRV_CPU_PROGRAM_MAP(cpu2_map)
301
302   MDRV_QUANTUM_TIME(HZ(6000))   /* we need heavy synch */
303
304   MDRV_MACHINE_START(ddrible)
305   MDRV_MACHINE_RESET(ddrible)
306
307   /* video hardware */
308   MDRV_SCREEN_ADD("screen", RASTER)
309   MDRV_SCREEN_REFRESH_RATE(60)
310   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
311   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
312   MDRV_SCREEN_SIZE(32*8, 32*8)
313   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
314/*  MDRV_SCREEN_SIZE(64*8, 32*8)
315    MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 2*8, 30*8-1) */
316
317   MDRV_GFXDECODE(ddrible)
318   MDRV_PALETTE_LENGTH(64 + 256)
319
320   MDRV_PALETTE_INIT(ddrible)
321   MDRV_VIDEO_START(ddrible)
322   MDRV_VIDEO_UPDATE(ddrible)
323
324   /* sound hardware */
325   MDRV_SPEAKER_STANDARD_MONO("mono")
326
327   MDRV_SOUND_ADD("ymsnd", YM2203, XTAL_3_579545MHz) /* verified on pcb */
328   MDRV_SOUND_CONFIG(ym2203_config)
329   MDRV_SOUND_ROUTE(0, "filter1", 0.25)
330   MDRV_SOUND_ROUTE(1, "filter2", 0.25)
331   MDRV_SOUND_ROUTE(2, "filter3", 0.25)
332   MDRV_SOUND_ROUTE(3, "mono", 0.25)
333
334   MDRV_SOUND_ADD("vlm", VLM5030, XTAL_3_579545MHz) /* verified on pcb */
335   MDRV_SOUND_CONFIG(vlm5030_config)
336   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
337
338   MDRV_SOUND_ADD("filter1", FILTER_RC, 0)
339   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
340   MDRV_SOUND_ADD("filter2", FILTER_RC, 0)
341   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
342   MDRV_SOUND_ADD("filter3", FILTER_RC, 0)
343   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
344MACHINE_DRIVER_END
345
346
347ROM_START( ddribble )
348   ROM_REGION( 0x1a000, "maincpu", 0 ) /* 64K CPU #0 + 40K for Banked ROMS */
349   ROM_LOAD( "690c03.bin",   0x10000, 0x0a000, CRC(07975a58) SHA1(96fd1b2348bbdf560067d8ee3cd4c0514e263d7a) )
350   ROM_CONTINUE(         0x0a000, 0x06000 )
351
352   ROM_REGION( 0x10000, "cpu1", 0 ) /* 64 for the CPU #1 */
353   ROM_LOAD( "690c02.bin", 0x08000, 0x08000, CRC(f07c030a) SHA1(db96a10f8bb657bf285266db9e775fa6af82f38c) )
354
355   ROM_REGION( 0x10000, "cpu2", 0 )   /* 64k for the SOUND CPU */
356   ROM_LOAD( "690b01.bin", 0x08000, 0x08000, CRC(806b8453) SHA1(3184772c5e5181438a17ac72129070bf164b2965) )
357
358   ROM_REGION( 0x40000, "gfx1", 0 )
359   ROM_LOAD16_BYTE( "690a05.bin",   0x00000, 0x20000, CRC(6a816d0d) SHA1(73f2527d5f2b9d51b784be36e07e0d0c566a28d9) )   /* characters & objects */
360   ROM_LOAD16_BYTE( "690a06.bin",   0x00001, 0x20000, CRC(46300cd0) SHA1(07197a546fff452a41575fcd481da64ac6bf601e) )
361
362   ROM_REGION( 0x80000, "gfx2", 0 )
363   ROM_LOAD16_BYTE( "690a10.bin", 0x00000, 0x20000, CRC(61efa222) SHA1(bd7b993ad1c06d8f6ac29fbc07c4a987abe1ab42) )   /* characters */
364   ROM_LOAD16_BYTE( "690a09.bin", 0x00001, 0x20000, CRC(ab682186) SHA1(a28982835042a07354557e1539b097cdf93fc466) )
365   ROM_LOAD16_BYTE( "690a08.bin", 0x40000, 0x20000, CRC(9a889944) SHA1(ca96815aefb1e336bd2288841b00a5c21cacf90f) )   /* objects */
366   ROM_LOAD16_BYTE( "690a07.bin", 0x40001, 0x20000, CRC(faf81b3f) SHA1(0bd647b4cdd3f2209472e303fd22eedd5533d1b1) )
367
368   ROM_REGION( 0x0100, "proms", 0 )
369   ROM_LOAD( "690a11.i15", 0x0000, 0x0100, CRC(f34617ad) SHA1(79ceba6fe204472a5a659641ac4f14bb1f0ee3f6) )   /* sprite lookup table */
370
371   ROM_REGION( 0x20000, "vlm", 0 )   /* 128k for the VLM5030 data */
372   ROM_LOAD( "690a04.bin", 0x00000, 0x20000, CRC(1bfeb763) SHA1(f3e9acb2a7a9b4c8dee6838c1344a7a65c27ff77) )
373
374   ROM_REGION( 0x0100, "plds", 0 )
375   ROM_LOAD( "pal10l8-007553.bin", 0x0000, 0x002c, CRC(0ae5a161) SHA1(87571addf434b332019ea0e22372eb24b4fd0197) )
376ROM_END
377
378
379GAME( 1986, ddribble, 0, ddribble, ddribble, 0, ROT0, "Konami", "Double Dribble", GAME_SUPPORTS_SAVE )
src/mame/drivers/segamsys.h
r7482r7483
1/* System E stuff */
2
3enum sms_mapper
4{
5   MAPPER_STANDARD = 0,
6   MAPPER_CODEMASTERS = 1
7};
8
9ADDRESS_MAP_EXTERN( sms_io_map, 8 );
10
11extern VIDEO_UPDATE(megatech_bios);
12extern VIDEO_UPDATE(megaplay_bios);
13extern VIDEO_UPDATE(megatech_md_sms);
14extern DRIVER_INIT( megatech_bios );
15extern DRIVER_INIT( hazemd_segasyse );
16extern MACHINE_RESET(megatech_bios);
17extern MACHINE_RESET(megatech_md_sms);
18extern VIDEO_EOF(megatech_bios);
19extern VIDEO_EOF(megatech_md_sms);
20
21extern READ8_HANDLER( sms_vcounter_r );
22extern READ8_HANDLER( sms_vdp_data_r );
23extern WRITE8_HANDLER( sms_vdp_data_w );
24extern READ8_HANDLER( sms_vdp_ctrl_r );
25extern WRITE8_HANDLER( sms_vdp_ctrl_w );
26
27extern void init_for_megadrive(running_machine *machine);
28extern void segae_md_sms_stop_scanline_timer(void);
29
30
31extern READ8_HANDLER( md_sms_vdp_vcounter_r );
32extern READ8_HANDLER( md_sms_vdp_data_r );
33extern WRITE8_HANDLER( md_sms_vdp_data_w );
34extern READ8_HANDLER( md_sms_vdp_ctrl_r );
35extern WRITE8_HANDLER( md_sms_vdp_ctrl_w );
36
37extern VIDEO_START(sms);
38extern VIDEO_EOF(sms);
39extern MACHINE_RESET(sms);
40extern READ8_HANDLER( sms_vdp_2_data_r );
41extern WRITE8_HANDLER( sms_vdp_2_data_w );
42extern READ8_HANDLER( sms_vdp_2_ctrl_r );
43extern WRITE8_HANDLER( sms_vdp_2_ctrl_w );
44extern VIDEO_EOF(systeme);
45extern VIDEO_UPDATE(systeme);
46extern MACHINE_RESET(systeme);
47extern UINT8* sms_mainram;
48extern UINT8* vdp2_vram_bank0;
49extern UINT8* vdp2_vram_bank1;
50extern UINT8* vdp1_vram_bank0;
51extern UINT8* vdp1_vram_bank1;
52extern void segae_set_vram_banks(UINT8 data);
53READ8_HANDLER( sms_ioport_gg00_r );
54void init_extra_gg_ports(running_machine* machine, const char* tag);
55READ8_HANDLER (megatech_sms_ioport_dc_r);
56READ8_HANDLER (megatech_sms_ioport_dd_r);
57READ8_HANDLER( smsgg_backupram_r );
58WRITE8_HANDLER( smsgg_backupram_w );
59extern void megatech_set_genz80_as_sms_standard_map(running_machine *machine, const char* tag, int mapper);
60MACHINE_DRIVER_EXTERN(sms);
61extern DRIVER_INIT(sms);
62extern DRIVER_INIT(smspal);
63extern DRIVER_INIT(smscm);
64extern DRIVER_INIT( smsgg );
65
66INPUT_PORTS_EXTERN(sms);
67INPUT_PORTS_EXTERN(gamegear);
68extern UINT8* smsgg_backupram;
69
70
71
72
73
src/mame/drivers/megadriv.h
r7482r7483
1#define MASTER_CLOCK_NTSC 53693175
2#define MASTER_CLOCK_PAL  53203424
3#define SEGACD_CLOCK      12500000
4
5
6extern DRIVER_INIT( megadriv_c2 );
7extern DRIVER_INIT( megadrie );
8extern DRIVER_INIT( megadriv );
9extern DRIVER_INIT( megadrij );
10extern DRIVER_INIT( _32x );
11extern DRIVER_INIT( mpnew );
12
13INPUT_PORTS_EXTERN( md_common );
14INPUT_PORTS_EXTERN( megadriv );
15INPUT_PORTS_EXTERN( aladbl );
16INPUT_PORTS_EXTERN( megadri6 );
17INPUT_PORTS_EXTERN( ssf2ghw );
18INPUT_PORTS_EXTERN( megdsvp );
19
20MACHINE_DRIVER_EXTERN( megadriv_timers );
21
22MACHINE_DRIVER_EXTERN( megdsvppal );
23MACHINE_DRIVER_EXTERN( megadriv );
24MACHINE_DRIVER_EXTERN( megadpal );
25MACHINE_DRIVER_EXTERN( megdsvp );
26MACHINE_DRIVER_EXTERN( genesis_32x );
27MACHINE_DRIVER_EXTERN( genesis_32x_pal );
28MACHINE_DRIVER_EXTERN( genesis_scd );
29MACHINE_DRIVER_EXTERN( genesis_32x_scd );
30MACHINE_DRIVER_EXTERN( md_bootleg );   // for topshoot.c & hshavoc.c
31
32extern UINT16* megadriv_backupram;
33extern int megadriv_backupram_length;
34extern UINT16* megadrive_ram;
35extern UINT8 megatech_bios_port_cc_dc_r(running_machine *machine, int offset, int ctrl);
36extern void megadriv_stop_scanline_timer(void);
37
38void megatech_set_megadrive_z80_as_megadrive_z80(running_machine *machine, const char* tag);
39
40extern READ16_HANDLER( megadriv_vdp_r );
41extern WRITE16_HANDLER( megadriv_vdp_w );
42
43/* These handlers are needed by megaplay.c */
44extern READ16_HANDLER( megadriv_68k_io_read );
45extern WRITE16_HANDLER( megadriv_68k_io_write );
46
47/* These handlers are needed by puckpkmn.c for his memory map */
48extern READ8_DEVICE_HANDLER( megadriv_68k_YM2612_read);
49extern WRITE8_DEVICE_HANDLER( megadriv_68k_YM2612_write);
50
51/* These are needed to create external input handlers (see e.g. MESS) */
52/* Regs are also used by Megaplay! */
53extern UINT8 (*megadrive_io_read_data_port_ptr)(running_machine *machine, int offset);
54extern void (*megadrive_io_write_data_port_ptr)(running_machine *machine, int offset, UINT16 data);
55extern UINT8 megadrive_io_data_regs[3];
56extern UINT8 megadrive_io_ctrl_regs[3];
57
58MACHINE_START( megadriv );
59MACHINE_RESET( megadriv );
60VIDEO_START( megadriv );
61VIDEO_UPDATE( megadriv );
62VIDEO_EOF( megadriv );
63
64
65extern UINT16* megadrive_vdp_palette_lookup;
66extern UINT16* megadrive_vdp_palette_lookup_sprite; // for C2
67extern UINT16* megadrive_vdp_palette_lookup_shadow;
68extern UINT16* megadrive_vdp_palette_lookup_highlight;
69
70extern int segac2_bg_pal_lookup[4];
71extern int segac2_sp_pal_lookup[4];
72
73extern int genvdp_use_cram;
74extern int genesis_always_irq6;
75extern int genesis_other_hacks;
76
77
78/* Megaplay - Megatech specific */
79/* It might be possible to move the following structs in the drivers */
80
81#define MP_ROM  0x10
82#define MP_GAME 0
83
84struct _mplay_bios   /* once all the regs are saved in this structure, it would be better to reorganize it a bit... */
85{
86   UINT32 bios_mode;  // determines whether ROM banks or Game data
87                           // is to read from 0x8000-0xffff
88
89   UINT32 bios_bank; // ROM bank selection
90   UINT16 game_banksel;  // Game bank selection
91   UINT32 readpos;  // serial bank selection position (9-bit)
92   UINT32 mp_bios_bank_addr;
93
94   UINT32 bios_width;  // determines the way the game info ROM is read
95   UINT8 bios_ctrl[6];
96   UINT8 bios_6600;
97   UINT8 bios_6403;
98   UINT8 bios_6404;
99};
100
101extern struct _mplay_bios mplay_bios;   // defined in megaplay.c
102
103struct _mtech_bios   /* once all the regs are saved in this structure, it would be better to reorganize it a bit... */
104{
105   UINT8 mt_cart_select_reg;
106   UINT32 bios_port_ctrl;
107   int current_game_is_sms; // is the current game SMS based (running on genesis z80, in VDP compatibility mode)
108   UINT32 bios_ctrl_inputs;
109   UINT8 bios_ctrl[6];
110
111   int mt_bank_bank_pos;
112   int mt_bank_partial;
113   int mt_bank_addr;
114};

Previous 15994 Revisions Next


© 1998-2018 The MESS Team