Previous 15994 Revisions Next

r978 Sunday 16th September, 2007 at 10:57:28 UTC by Wilbert Pol
[PCE] Added a seperate VCE struct and took VCE related entries out of the VDC struct.
[src/mess/video]vdc.c

src/mess/video/vdc.c
r977r978
2525   int dvssr_write;         /* Set when the DVSSR register has been written to */
2626   int physical_width;         /* Width of the display */
2727   int physical_height;      /* Height of the display */
28   UINT8 vce_control;         /* VCE control register */
29   pair vce_address;         /* Current address in the palette */
30   pair vce_data[512];         /* Palette data */
3128   UINT16 sprite_ram[64*4];   /* Sprite RAM */
3229   int curline;            /* the current scanline we're on */
33   int current_bitmap_line;   /* the current line in the display we are on */
3430   int current_segment;      /* current segment of display */
3531   int current_segment_line;   /* current line inside a segment of display */
3632   int vblank_triggered;      /* to indicate whether vblank has been triggered */
r977r978
4238   UINT8 vdc_latch;
4339   pair vdc_data[32];
4440   int status;
45   mame_bitmap *bmp;
4641   int y_scroll;
4742}VDC;
4843
44typedef struct {
45   UINT8   vce_control;         /* VCE control register */
46   pair   vce_address;         /* Current address in the palette */
47   pair   vce_data[512];         /* Palette data */
48   int      current_bitmap_line;   /* The current line in the display we are on */
49   mame_bitmap   *bmp;
50}VCE;
51
4952static VDC vdc;
53static VCE vce;
5054
5155/* Function prototypes */
5256
r977r978
6165   int ret = 0;
6266
6367   /* Draw the last scanline */
64   if ( vdc.current_bitmap_line >= 14 && vdc.current_bitmap_line < 14 + 242 ) {
68   if ( vce.current_bitmap_line >= 14 && vce.current_bitmap_line < 14 + 242 ) {
6569      /* We are in the active display area */
6670      if ( vdc.current_segment == STATE_VDW ) {
6771         vdc.y_scroll = ( vdc.current_segment_line == 0 ) ? vdc.vdc_data[BYR].w : ( vdc.y_scroll + 1 );
68         pce_refresh_line( vdc.current_bitmap_line, vdc.current_segment_line );
72         pce_refresh_line( vce.current_bitmap_line, vdc.current_segment_line );
6973      } else {
70         draw_overscan_line( vdc.current_bitmap_line );
74         draw_overscan_line( vce.current_bitmap_line );
7175      }
7276   } else {
7377      /* We are in one of the blanking areas */
74      draw_black_line( vdc.current_bitmap_line );
78      draw_black_line( vce.current_bitmap_line );
7579   }
7680
7781   /* bump current scanline */
78   vdc.current_bitmap_line = ( vdc.current_bitmap_line + 1 ) % VDC_LPF;
82   vce.current_bitmap_line = ( vce.current_bitmap_line + 1 ) % VDC_LPF;
7983   vdc.curline += 1;
8084   vdc.current_segment_line += 1;
8185   vdc.raster_count += 1;
r977r978
9094      }
9195   }
9296
93   if ( vdc.current_bitmap_line == 0 ) {
97   if ( vce.current_bitmap_line == 0 ) {
9498      vdc.current_segment = STATE_VSW;
9599      vdc.current_segment_line = 0;
96100      vdc.vblank_triggered = 0;
r977r978
188192
189193   /* clear context */
190194   memset(&vdc, 0, sizeof(vdc));
195   memset(&vce, 0, sizeof(vce));
191196
192197   /* allocate VRAM */
193198   vdc.vram = auto_malloc(0x10000);
194199   memset(vdc.vram, 0, 0x10000);
195200
196201   /* create display bitmap */
197   vdc.bmp = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
202   vce.bmp = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
198203
199204   vdc.inc = 1;
200205}
r977r978
203208VIDEO_UPDATE( pce )
204209{
205210   /* copy our rendering buffer to the display */
206   copybitmap (bitmap,vdc.bmp,0,0,0,0,cliprect,TRANSPARENCY_NONE,0);
211   copybitmap (bitmap,vce.bmp,0,0,0,0,cliprect,TRANSPARENCY_NONE,0);
207212   return 0;
208213}
209214
r977r978
212217   int i;
213218
214219   /* our line buffer */
215   UINT16 *line_buffer = BITMAP_ADDR16( vdc.bmp, line, 0 );
220   UINT16 *line_buffer = BITMAP_ADDR16( vce.bmp, line, 0 );
216221   
217222   for( i=0; i< VDC_WPF; i++ )
218223      line_buffer[i] = get_black_pen( Machine );
r977r978
223228   int i;
224229
225230   /* Are we in greyscale mode or in color mode? */
226   int color_base = vdc.vce_control & 0x80 ? 512 : 0;
231   int color_base = vce.vce_control & 0x80 ? 512 : 0;
227232
228233   /* our line buffer */
229   UINT16 *line_buffer = BITMAP_ADDR16( vdc.bmp, line, 0 );
234   UINT16 *line_buffer = BITMAP_ADDR16( vce.bmp, line, 0 );
230235   
231236   for ( i = 0; i < VDC_WPF; i++ )
232      line_buffer[i] = Machine->pens[color_base + vdc.vce_data[0x100].w];
237      line_buffer[i] = Machine->pens[color_base + vce.vce_data[0x100].w];
233238
234239}
235240
r977r978
397402   switch(offset & 7)
398403   {
399404      case 0x04:   /* color table data (LSB) */
400         temp = vdc.vce_data[vdc.vce_address.w].b.l;
405         temp = vce.vce_data[vce.vce_address.w].b.l;
401406         break;
402407
403408      case 0x05:   /* color table data (MSB) */
404         temp = vdc.vce_data[vdc.vce_address.w].b.h;
409         temp = vce.vce_data[vce.vce_address.w].b.h;
405410         temp |= 0xFE;
406         vdc.vce_address.w = (vdc.vce_address.w + 1) & 0x01FF;
411         vce.vce_address.w = (vce.vce_address.w + 1) & 0x01FF;
407412         break;
408413   }
409414   return (temp);
r977r978
415420   switch(offset & 7)
416421   {
417422      case 0x00:   /* control reg. */
418         vdc.vce_control = data;
423         vce.vce_control = data;
419424         break;
420425
421426      case 0x02:   /* color table address (LSB) */
422         vdc.vce_address.b.l = data;
423         vdc.vce_address.w &= 0x1FF;
427         vce.vce_address.b.l = data;
428         vce.vce_address.w &= 0x1FF;
424429         break;
425430
426431      case 0x03:   /* color table address (MSB) */
427         vdc.vce_address.b.h = data;
428         vdc.vce_address.w &= 0x1FF;
432         vce.vce_address.b.h = data;
433         vce.vce_address.w &= 0x1FF;
429434         break;
430435
431436      case 0x04:   /* color table data (LSB) */
432         vdc.vce_data[vdc.vce_address.w].b.l = data;
437         vce.vce_data[vce.vce_address.w].b.l = data;
433438         break;
434439
435440      case 0x05:   /* color table data (MSB) */
436         vdc.vce_data[vdc.vce_address.w].b.h = data & 0x01;
441         vce.vce_data[vce.vce_address.w].b.h = data & 0x01;
437442
438443         /* bump internal address */
439         vdc.vce_address.w = (vdc.vce_address.w + 1) & 0x01FF;
444         vce.vce_address.w = (vce.vce_address.w + 1) & 0x01FF;
440445         break;
441446   }
442447}
r977r978
463468    int v_width =        width_table[(vdc.vdc_data[MWR].w >> 4) & 3];
464469
465470    /* our line buffer */
466    UINT16 *line_buffer = BITMAP_ADDR16( vdc.bmp, bitmap_line, 86 );
471    UINT16 *line_buffer = BITMAP_ADDR16( vce.bmp, bitmap_line, 86 );
467472
468473    /* pointer to the name table (Background Attribute Table) in VRAM */
469474    UINT8 *bat = &(vdc.vram[nt_row << (v_width+1)]);
r977r978
474479   UINT8 drawn[VDC_WPF];
475480
476481   /* Are we in greyscale mode or in color mode? */
477   int color_base = vdc.vce_control & 0x80 ? 512 : 0;
482   int color_base = vce.vce_control & 0x80 ? 512 : 0;
478483
479484    int b0, b1, b2, b3;
480485    int i0, i1, i2, i3;
r977r978
497502
498503      /* First fill line with overscan colour */
499504      for ( i = -86; i < VDC_WPF - 86; i++ )
500         line_buffer[i] = Machine->pens[color_base + vdc.vce_data[0x100].w];
505         line_buffer[i] = Machine->pens[color_base + vce.vce_data[0x100].w];
501506
502507      for(i=0;i<(vdc.physical_width >> 3) + 1;i++)
503508      {
r977r978
534539
535540            if ( phys_x >= 0 && phys_x < vdc.physical_width ) {
536541               drawn[ phys_x ] = c ? 1 : 0;
537               line_buffer[ pixel ] = Machine->pens[color_base + vdc.vce_data[c].w];
542               line_buffer[ pixel ] = Machine->pens[color_base + vce.vce_data[c].w];
538543               pixel++;
539544               if ( vdc.physical_width != 512 ) {
540545                  if ( pixel < ( ( ( phys_x + 1 ) * 512 ) / vdc.physical_width ) ) {
541                     line_buffer[ pixel ] = Machine->pens[color_base + vdc.vce_data[c].w];
546                     line_buffer[ pixel ] = Machine->pens[color_base + vce.vce_data[c].w];
542547                     pixel++;
543548                  }
544549               }
r977r978
591596{
592597    int i;
593598   UINT8 sprites_drawn=0;
594   UINT16 *line_buffer= BITMAP_ADDR16( vdc.bmp, bitmap_line, 86 );
599   UINT16 *line_buffer= BITMAP_ADDR16( vce.bmp, bitmap_line, 86 );
595600
596601   /* Are we in greyscale mode or in color mode? */
597   int color_base = vdc.vce_control & 0x80 ? 512 : 0;
602   int color_base = vce.vce_control & 0x80 ? 512 : 0;
598603
599604   /* count up: Highest priority is Sprite 0 */
600605   for(i=0; i<64; i++)
r977r978
662667                  if ( buf[x] ) {
663668                     if( drawn[obj_x+x] < 2 ) {
664669                        if(priority || drawn[obj_x+x] == 0 ) {
665                           line_buffer[pixel_x] = Machine->pens[color_base + vdc.vce_data[0x100 + (palette << 4) + buf[x]].w];
670                           line_buffer[pixel_x] = Machine->pens[color_base + vce.vce_data[0x100 + (palette << 4) + buf[x]].w];
666671                           if ( vdc.physical_width != 512 ) {
667672                              if ( pixel_x + 1 < ( ( ( obj_x + x + 1 ) * 512 ) / vdc.physical_width ) ) {
668                                 line_buffer[pixel_x + 1] = Machine->pens[color_base + vdc.vce_data[0x100 + (palette << 4) + buf[x]].w];
673                                 line_buffer[pixel_x + 1] = Machine->pens[color_base + vce.vce_data[0x100 + (palette << 4) + buf[x]].w];
669674                              }
670675                           }
671676                        }
r977r978
702707                  if ( buf[x] ) {
703708                     if( drawn[obj_x+x] < 2 ) {
704709                        if ( priority || drawn[obj_x+x] == 0 ) {
705                           line_buffer[pixel_x] = Machine->pens[color_base + vdc.vce_data[0x100 + (palette << 4) + buf[x]].w];
710                           line_buffer[pixel_x] = Machine->pens[color_base + vce.vce_data[0x100 + (palette << 4) + buf[x]].w];
706711                           if ( vdc.physical_width != 512 ) {
707712                              if ( pixel_x + 1 < ( ( ( obj_x + x + 1 ) * 512 ) / vdc.physical_width ) ) {
708                                 line_buffer[pixel_x + 1] = Machine->pens[color_base + vdc.vce_data[0x100 + (palette << 4) + buf[x]].w];
713                                 line_buffer[pixel_x + 1] = Machine->pens[color_base + vce.vce_data[0x100 + (palette << 4) + buf[x]].w];
709714                              }
710715                           }
711716                        }
r977r978
744749                     if ( buf[x] ) {
745750                        if( drawn[obj_x+0x10+x] < 2 ) {
746751                           if( priority || drawn[obj_x+0x10+x] == 0 ) {
747                              line_buffer[pixel_x] = Machine->pens[color_base + vdc.vce_data[0x100 + (palette << 4) + buf[x]].w];
752                              line_buffer[pixel_x] = Machine->pens[color_base + vce.vce_data[0x100 + (palette << 4) + buf[x]].w];
748753                              if ( vdc.physical_width != 512 ) {
749754                                 if ( pixel_x + 1 < ( ( ( obj_x + x + 17 ) * 512 ) / vdc.physical_width ) ) {
750                                    line_buffer[pixel_x + 1] = Machine->pens[color_base + vdc.vce_data[0x100 + (palette << 4) + buf[x]].w];
755                                    line_buffer[pixel_x + 1] = Machine->pens[color_base + vce.vce_data[0x100 + (palette << 4) + buf[x]].w];
751756                                 }
752757                              }                                   
753758                           }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team