Previous 15994 Revisions Next

r1183 Tuesday 23rd October, 2007 at 20:26:34 UTC by Wilbert Pol
[SVI318] Updated to use MAME's crtc 6845 implementation.
[src/mess/machine]svi318.c

src/mess/machine/svi318.c
r1182r1183
2323#include "sound/dac.h"
2424#include "sound/ay8910.h"
2525#include "image.h"
26#include "video/crtc6845.h"
2627
2728enum {
2829   SVI_INTERNAL   = 0,
r1182r1183
405406
406407/* 80 column card */
407408
408#include "video/m6845.h"
409409static int svi318_80col_state;
410410static char *svi318_80col_ram = NULL;
411411
412static int svi318_6845_RA = 0;
413static int svi318_scr_x = 0;
414static int svi318_scr_y = 0;
415static int svi318_HSync = 0;
416static int svi318_VSync = 0;
417static int svi318_DE = 0;
412//static int svi318_6845_RA = 0;
413//static int svi318_scr_x = 0;
414//static int svi318_scr_y = 0;
415//static int svi318_HSync = 0;
416//static int svi318_VSync = 0;
417//static int svi318_DE = 0;
418//
419//// called when the 6845 changes the character row
420//static void svi318_Set_RA(int offset, int data)
421//{
422//   svi318_6845_RA=data;
423//}
424//
425//
426//// called when the 6845 changes the HSync
427//static void svi318_Set_HSync(int offset, int data)
428//{
429//   svi318_HSync=data;
430//   if(!svi318_HSync)
431//   {
432//      svi318_scr_y++;
433//      svi318_scr_x = -40;
434//   }
435//}
436//
437//// called when the 6845 changes the VSync
438//static void svi318_Set_VSync(int offset, int data)
439//{
440//   svi318_VSync=data;
441//   if (!svi318_VSync)
442//   {
443//      svi318_scr_y = 0;
444//   }
445//}
446//
447//static void svi318_Set_DE(int offset, int data)
448//{
449//   svi318_DE = data;
450//}
451//
452//static struct m6845_interface
453//svi318_m6845_interface= {
454//   0,// Memory Address register
455//   svi318_Set_RA,// Row Address register
456//   svi318_Set_HSync,// Horizontal status
457//   svi318_Set_VSync,// Vertical status
458//   svi318_Set_DE,// Display Enabled status
459//   0,// Cursor status
460//};
418461
419// called when the 6845 changes the character row
420static void svi318_Set_RA(int offset, int data)
421{
422   svi318_6845_RA=data;
462static void svi318_crtc6845_update_row(mame_bitmap *bitmap, const rectangle *cliprect, UINT16 ma,
463                              UINT8 ra, UINT16 y, UINT8 x_count, void *param ) {
423464}
424465
425
426// called when the 6845 changes the HSync
427static void svi318_Set_HSync(int offset, int data)
428{
429   svi318_HSync=data;
430   if(!svi318_HSync)
431   {
432      svi318_scr_y++;
433      svi318_scr_x = -40;
434   }
435}
436
437// called when the 6845 changes the VSync
438static void svi318_Set_VSync(int offset, int data)
439{
440   svi318_VSync=data;
441   if (!svi318_VSync)
442   {
443      svi318_scr_y = 0;
444   }
445}
446
447static void svi318_Set_DE(int offset, int data)
448{
449   svi318_DE = data;
450}
451
452static struct m6845_interface
453svi318_m6845_interface= {
454   0,// Memory Address register
455   svi318_Set_RA,// Row Address register
456   svi318_Set_HSync,// Horizontal status
457   svi318_Set_VSync,// Vertical status
458   svi318_Set_DE,// Display Enabled status
459   0,// Cursor status
466static const crtc6845_interface svi318_crtc6845_interface = {
467   0,
468   3579545 /*?*/,
469   8 /*?*/,
470   NULL,
471   svi318_crtc6845_update_row,
472   NULL,
473   NULL
460474};
461475
462476/* 80 column card init */
r1182r1183
464478{
465479   /* 2K RAM */
466480   svi318_80col_ram = auto_malloc(0x800);
467memset(svi318_80col_ram, 0x40, 0x400);
481   memset(svi318_80col_ram, 0x40, 0x400);
468482   /* initialise 6845 */
469   m6845_config(&svi318_m6845_interface);
483   crtc6845_config( 0, &svi318_crtc6845_interface);
470484
471485   svi318_80col_state=(1<<2)|(1<<1);
472486}
r1182r1183
484498{
485499}
486500
487static void svi318_80col_plot_char_line(int x,int y, mame_bitmap *bitmap)
488{
489   int w;
490   if (svi318_DE)
491   {
492      unsigned char *data = memory_region(REGION_GFX1);
493      unsigned char data_byte;
494      int char_code;
495
496      char_code = svi318_80col_ram[m6845_memory_address_r(0)&0x07ff];
497     
498      data_byte = data[(char_code<<3) + svi318_6845_RA];
499
500      for (w=0; w<8;w++)
501      {
502         *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0;
503
504         data_byte = data_byte<<1;
505
506      }
507   }
508   else
509   {
510      for (w=0; w<8;w++)
511         *BITMAP_ADDR16(bitmap, y, x+w) = 0;
512   }
513
514}
515
501//static void svi318_80col_plot_char_line(int x,int y, mame_bitmap *bitmap)
502//{
503//   int w;
504//   if (svi318_DE)
505//   {
506//      unsigned char *data = memory_region(REGION_GFX1);
507//      unsigned char data_byte;
508//      int char_code;
509//
510//      char_code = svi318_80col_ram[m6845_memory_address_r(0)&0x07ff];
511//     
512//      data_byte = data[(char_code<<3) + svi318_6845_RA];
513//
514//      for (w=0; w<8;w++)
515//      {
516//         *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0;
517//
518//         data_byte = data_byte<<1;
519//
520//      }
521//   }
522//   else
523//   {
524//      for (w=0; w<8;w++)
525//         *BITMAP_ADDR16(bitmap, y, x+w) = 0;
526//   }
527//
528//}
529//
516530static VIDEO_UPDATE( svi318_80col )
517531{
518532   long c=0; // this is used to time out the screen redraw, in the case that the 6845 is in some way out state.
r1182r1183
520534   c=0;
521535
522536   // loop until the end of the Vertical Sync pulse
523   while((svi318_VSync)&&(c<33274))
524   {
525      // Clock the 6845
526      m6845_clock();
527      c++;
528   }
529
530   // loop until the Vertical Sync pulse goes high
531   // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal)
532   while((!svi318_VSync)&&(c<33274))
533   {
534      while ((svi318_HSync)&&(c<33274))
535      {
536         m6845_clock();
537         c++;
538      }
539      // Do all the clever split mode changes in here before the next while loop
540
541      while ((!svi318_HSync)&&(c<33274))
542      {
543         // check that we are on the emulated screen area.
544         if ((svi318_scr_x>=0) && (svi318_scr_x<640) && (svi318_scr_y>=0) && (svi318_scr_y<400))
545         {
546            svi318_80col_plot_char_line(svi318_scr_x, svi318_scr_y, bitmap);
547         }
548
549         svi318_scr_x+=8;
550
551         // Clock the 6845
552         m6845_clock();
553         c++;
554      }
555   }
537//   while((svi318_VSync)&&(c<33274))
538//   {
539//      // Clock the 6845
540//      m6845_clock();
541//      c++;
542//   }
543//
544//   // loop until the Vertical Sync pulse goes high
545//   // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal)
546//   while((!svi318_VSync)&&(c<33274))
547//   {
548//      while ((svi318_HSync)&&(c<33274))
549//      {
550//         m6845_clock();
551//         c++;
552//      }
553//      // Do all the clever split mode changes in here before the next while loop
554//
555//      while ((!svi318_HSync)&&(c<33274))
556//      {
557//         // check that we are on the emulated screen area.
558//         if ((svi318_scr_x>=0) && (svi318_scr_x<640) && (svi318_scr_y>=0) && (svi318_scr_y<400))
559//         {
560//            svi318_80col_plot_char_line(svi318_scr_x, svi318_scr_y, bitmap);
561//         }
562//
563//         svi318_scr_x+=8;
564//
565//         // Clock the 6845
566//         m6845_clock();
567//         c++;
568//      }
569//   }
556570   return 0;
557571}
558572

Previous 15994 Revisions Next


© 1998-2018 The MESS Team