Previous 15994 Revisions Next

r2548 Monday 5th May, 2008 at 17:17:46 UTC by Wilbert Pol
[PC CGA] Implemented cursor blinking. Styling updates.
[src/mess/video]pc_cga.c

src/mess/video/pc_cga.c
r2547r2548
4545
4646   (source John Elliott http://www.seasip.info/AmstradXT/pc1512disp.html)
4747
48
49  Cursor signal handling:
50
51  The alpha dots signal is set when a character pixel should be set. This signal is
52  also set when the cursor should be displayed. The following formula for alpha
53  dots is derived from the schematics:
54  ALPHA DOTS = ( ( CURSOR DLY ) AND ( CURSOR BLINK ) ) OR ( ( ( NOT AT7 ) OR CURSOR DLY OR -BLINK OR NOT ENABLE BLINK ) AND ( CHG DOTS ) )
55
56  -CURSOR BLINK = VSYNC DLY (LS393) (changes every 8 vsyncs)
57  -BLINK = -CURSOR BLINK (LS393) (changes every 16 vsyncs)
58  -CURSOR DLY = -CURSOR signal from mc6845 and LS174
59  CHG DOTS = character pixel (from character rom)
60
61  For non-blinking modes this formula reduces to:
62  ALPHA DOTS = ( ( CURSOR DLY ) AND ( CURSOR BLINK ) ) OR ( CHG DOTS )
63
64  This means the cursor switches on/off state every 8 vsyncs.
65
66
67  For blinking modes this formula reduces to:
68  ALPHA DOTS = ( ( CURSOR DLY ) AND ( CURSOR BLINK ) ) OR ( ( ( NOT AT7 ) OR CURSOR DLY OR -BLINK ) AND ( CHG DOTS ) )
69
70  So, at the cursor location the attribute blinking is ignored and only regular
71  cursor blinking takes place (state switches every 8 vsyncs). On non-cursor
72  locations with the highest attribute bits set the character will switch
73  on/off every 16 vsyncs. In all other cases the character is displayed as
74  usual.
75
4876***************************************************************************/
4977
5078#include "driver.h"
r2547r2548
160188static VIDEO_UPDATE( mc6845_pc1512 );
161189
162190
163static const mc6845_interface mc6845_cga_intf = {
191static const mc6845_interface mc6845_cga_intf =
192{
164193   CGA_SCREEN_NAME,   /* screen number */
165194   XTAL_14_31818MHz/8,   /* clock */
166195   8,               /* numbers of pixels per video memory address */
r2547r2548
231260 *
232261 ***************************************************************************/
233262
234struct ntsc_decoder {
263struct ntsc_decoder
264{
235265   int period;
236266
237267   int *I_filter;
r2547r2548
248278
249279
250280/* Clear NTSC buffers and running totals. Call this before the beginning of each new line. */
251static void ntsc_clear(struct ntsc_decoder *ntsc) {
281static void ntsc_clear(struct ntsc_decoder *ntsc)
282{
252283   int j;
253   for (j=0;j<ntsc->period;++j) {
284   for (j=0;j<ntsc->period;++j)
285   {
254286      ntsc->Y_buffer[j] = 0;
255287      ntsc->I_buffer[j] = 0;
256288      ntsc->Q_buffer[j] = 0;
r2547r2548
274306
275307   The correct value for hue will usually be a multiple of 128.
276308*/
277static void ntsc_decoder_init(struct ntsc_decoder *ntsc, int period, int hue) {
309static void ntsc_decoder_init(struct ntsc_decoder *ntsc, int period, int hue)
310{
278311   int j;
279312
280313   ntsc->period = period;
r2547r2548
284317   ntsc->I_buffer = auto_malloc(period * sizeof(int));
285318   ntsc->Q_buffer = auto_malloc(period * sizeof(int));
286319   ntsc_clear(ntsc);
287   for (j=0;j<period;++j) {
320   for (j=0;j<period;++j)
321   {
288322      double angle = M_PI*((hue+(j<<8))/(period*128.0)-33.0/180);
289323      ntsc->I_filter[j] = (int)(512.0*cos(angle));
290324      ntsc->Q_filter[j] = (int)(512.0*sin(angle));
r2547r2548
302336   first call ntsc_decode(ntsc, input, NULL, 1) with "input" containing the
303337   samples directly before the samples you will subsequently be using.
304338*/
305static void ntsc_decode(struct ntsc_decoder *ntsc, UINT8 *input, UINT8 *output, int periods) {
339static void ntsc_decode(struct ntsc_decoder *ntsc, UINT8 *input, UINT8 *output, int periods)
340{
306341   int j;
307342
308343   int *I_filter;
r2547r2548
317352   int R,G,B;
318353   int period = ntsc->period;
319354
320   while ((--periods)>=0) {
355   while ((--periods)>=0)
356   {
321357      I_filter = ntsc->I_filter;
322358      Q_filter = ntsc->Q_filter;
323359      Y_buffer = ntsc->Y_buffer;
324360      I_buffer = ntsc->I_buffer;
325361      Q_buffer = ntsc->Q_buffer;
326362
327      for (j=0;j<period;++j) {
363      for (j=0;j<period;++j)
364      {
328365
329366         /* Get next point */
330367         Y = *(input++);
r2547r2548
385422{
386423   int i, r, g, b;
387424
388   for ( i = 0; i < CGA_PALETTE_SETS * 16; i++ ) {
425   for ( i = 0; i < CGA_PALETTE_SETS * 16; i++ )
426   {
389427      palette_set_color_rgb( machine, i, cga_palette[i][0], cga_palette[i][1], cga_palette[i][2] );
390428   }
391429
392430   i = 0x8000;
393   for ( r = 0; r < 32; r++ ) {
394      for ( g = 0; g < 32; g++ ) {
395         for ( b = 0; b < 32; b++ ) {
431   for ( r = 0; r < 32; r++ )
432   {
433      for ( g = 0; g < 32; g++ )
434      {
435         for ( b = 0; b < 32; b++ )
436         {
396437            palette_set_color_rgb( machine, i, r << 3, g << 3, b << 3 );
397438            i++;
398439         }
r2547r2548
477518   mc6845_update( devconf, bitmap, cliprect);
478519
479520   /* Check for changes in font dipsetting */
480   switch ( CGA_FONT & 0x01 ) {
521   switch ( CGA_FONT & 0x01 )
522   {
481523   case 0:
482524      cga.chr_gen = memory_region(REGION_GFX1) + 0x1800;
483525      break;
r2547r2548
494536  The character cell size is 16x8
495537***************************************************************************/
496538
497static MC6845_UPDATE_ROW( cga_text_inten_update_row ) {
539static MC6845_UPDATE_ROW( cga_text_inten_update_row )
540{
498541   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
499542   int i;
500543
501544   if ( y == 0 ) CGA_LOG(1,"cga_text_inten_update_row",("\n"));
502   for ( i = 0; i < x_count; i++ ) {
545   for ( i = 0; i < x_count; i++ )
546   {
503547      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
504548      UINT8 chr = videoram[ offset ];
505549      UINT8 attr = videoram[ offset +1 ];
r2547r2548
507551      UINT16 fg = attr & 0x0F;
508552      UINT16 bg = attr >> 4;
509553
510      if ( i == cursor_x ) {
554      if ( i == cursor_x && ( cga.frame & 0x08 ) )
555      {
511556         data = 0xFF;
512557      }
513558
r2547r2548
528573  The character cell size is 16x8. Composite monitor, greyscale.
529574***************************************************************************/
530575
531static MC6845_UPDATE_ROW( cga_text_inten_comp_grey_update_row ) {
576static MC6845_UPDATE_ROW( cga_text_inten_comp_grey_update_row )
577{
532578   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
533579   int i;
534580
535581   if ( y == 0 ) CGA_LOG(1,"cga_text_inten_update_row",("\n"));
536   for ( i = 0; i < x_count; i++ ) {
582   for ( i = 0; i < x_count; i++ )
583   {
537584      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
538585      UINT8 chr = videoram[ offset ];
539586      UINT8 attr = videoram[ offset +1 ];
r2547r2548
541588      UINT16 fg = 0x10 + ( attr & 0x0F );
542589      UINT16 bg = 0x10 + ( ( attr >> 4 ) & 0x07 );
543590
544      if ( i == cursor_x ) {
591      if ( i == cursor_x && ( cga.frame & 0x08 ) )
592      {
545593         data = 0xFF;
546594      }
547595
r2547r2548
561609  The character cell size is 16x8
562610***************************************************************************/
563611
564static MC6845_UPDATE_ROW( cga_text_inten_alt_update_row ) {
612static MC6845_UPDATE_ROW( cga_text_inten_alt_update_row )
613{
565614   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
566615   int i;
567616
568617   if ( y == 0 ) CGA_LOG(1,"cga_text_inten_alt_update_row",("\n"));
569   for ( i = 0; i < x_count; i++ ) {
618   for ( i = 0; i < x_count; i++ )
619   {
570620      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
571621      UINT8 chr = videoram[ offset ];
572622      UINT8 attr = videoram[ offset +1 ];
573623      UINT8 data = cga.chr_gen[ chr * 8 + ra ];
574624      UINT16 fg = attr & 0x0F;
575625
576      if ( i == cursor_x ) {
626      if ( i == cursor_x && ( cga.frame & 0x08 ) )
627      {
577628         data = 0xFF;
578629      }
579630
r2547r2548
594645  The character cell size is 16x8
595646***************************************************************************/
596647
597static MC6845_UPDATE_ROW( cga_text_blink_update_row ) {
648static MC6845_UPDATE_ROW( cga_text_blink_update_row )
649{
598650   UINT16   *p = BITMAP_ADDR16(bitmap, y, 0);
599651   int i;
600652
601653   if ( y == 0 ) CGA_LOG(1,"cga_text_blink_update_row",("\n"));
602   for ( i = 0; i < x_count; i++ ) {
654   for ( i = 0; i < x_count; i++ )
655   {
603656      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
604657      UINT8 chr = videoram[ offset ];
605658      UINT8 attr = videoram[ offset +1 ];
r2547r2548
607660      UINT16 fg = attr & 0x0F;
608661      UINT16 bg = attr >> 4;
609662
610      if ( i == cursor_x ) {
611         data = 0xFF;
612      } else {
613         if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) ) {
663      if ( i == cursor_x )
664      {
665         if ( cga.frame & 0x08 )
666         {
667            data = 0xFF;
668         }
669      }
670      else
671      {
672         if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) )
673         {
614674            data = 0x00;
615675         }
616676      }
r2547r2548
632692  The character cell size is 16x8
633693***************************************************************************/
634694
635static MC6845_UPDATE_ROW( cga_text_blink_alt_update_row ) {
695static MC6845_UPDATE_ROW( cga_text_blink_alt_update_row )
696{
636697   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
637698   int i;
638699
639700   if ( y == 0 ) CGA_LOG(1,"cga_text_blink_alt_update_row",("\n"));
640   for ( i = 0; i < x_count; i++ ) {
701   for ( i = 0; i < x_count; i++ )
702   {
641703      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
642704      UINT8 chr = videoram[ offset ];
643705      UINT8 attr = videoram[ offset +1 ];
r2547r2548
645707      UINT16 fg = attr & 0x07;
646708      UINT16 bg = 0;
647709
648      if ( i == cursor_x ) {
649         data = 0xFF;
650      } else {
651         if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) ) {
710      if ( i == cursor_x )
711      {
712         if ( cga.frame & 0x08 )
713         {
714            data = 0xFF;
715         }
716      }
717      else
718      {
719         if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) )
720         {
652721            data = 0x00;
653722            bg = ( attr >> 4 ) & 0x07;
654723         }
r2547r2548
668737
669738/* The lo-res (320x200) graphics mode on a colour composite monitor */
670739
671static MC6845_UPDATE_ROW( cga_gfx_4bppl_update_row ) {
740static MC6845_UPDATE_ROW( cga_gfx_4bppl_update_row )
741{
672742   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
673743   int i;
674744
675745   if ( y == 0 ) CGA_LOG(1,"cga_gfx_4bppl_update_row",("\n"));
676   for ( i = 0; i < x_count; i++ ) {
746   for ( i = 0; i < x_count; i++ )
747   {
677748      UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 );
678749      UINT8 data = videoram[ offset ];
679750
r2547r2548
700771
701772static const UINT8 yc_lut2[4] = { 0, 182, 71, 255 };
702773
703static const UINT8 yc_lut[16][8] = {
774static const UINT8 yc_lut[16][8] =
775{
704776   { 0, 0, 0, 0, 0, 0, 0, 0 },   /* black */
705777   { 0, 0, 0, 0, 1, 1, 1, 1 },   /* blue */
706778   { 0, 1, 1, 1, 1, 0, 0, 0 },   /* green */
r2547r2548
720792   { 3, 3, 3, 3, 3, 3, 3, 3 }, /* white */
721793};
722794
723static MC6845_UPDATE_ROW( cga_gfx_4bpph_update_row ) {
795static MC6845_UPDATE_ROW( cga_gfx_4bpph_update_row )
796{
724797   UINT8   samples[1280];
725798   UINT8   ntsc_decoded[3*1280];
726799   int      samp_index = 0;
r2547r2548
728801   int i;
729802
730803   if ( y == 0 ) CGA_LOG(1,"cga_gfx_4bpph_update_row",("\n"));
731if ( NTSC_FILTER ) {
804if ( NTSC_FILTER )
805{
732806   ntsc_clear( &ntsc );
733807   memset( ntsc_decoded, 0, sizeof(ntsc_decoded));
734808}
735   for ( i = 0; i < x_count; i++ ) {
809   for ( i = 0; i < x_count; i++ )
810   {
736811      UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 );
737812      UINT8 data = videoram[ offset ];
738813
739if ( NTSC_FILTER ) {
814if ( NTSC_FILTER )
815{
740816      samples[samp_index] = yc_lut2[yc_lut[data>>4][0]]; samp_index++;
741817      samples[samp_index] = yc_lut2[yc_lut[data>>4][1]]; samp_index++;
742818      samples[samp_index] = yc_lut2[yc_lut[data>>4][2]]; samp_index++;
r2547r2548
767843
768844      data = videoram[ offset + 1 ];
769845
770if ( NTSC_FILTER ) {
846if ( NTSC_FILTER )
847{
771848      samples[samp_index] = yc_lut2[yc_lut[data>>4][0]]; samp_index++;
772849      samples[samp_index] = yc_lut2[yc_lut[data>>4][1]]; samp_index++;
773850      samples[samp_index] = yc_lut2[yc_lut[data>>4][2]]; samp_index++;
r2547r2548
796873      *p = data & 0x0F; p++;
797874      *p = data & 0x0F; p++;
798875   }
799if (NTSC_FILTER) {
876if (NTSC_FILTER)
877{
800878   ntsc_decode( &ntsc, samples, ntsc_decoded, 160 );
801879   p = BITMAP_ADDR16(bitmap, y, 0);
802880   samp_index = 0;
803   for ( i = 0; i < ( 8 * x_count ); i++ ) {
881   for ( i = 0; i < ( 8 * x_count ); i++ )
882   {
804883      int r = ( ntsc_decoded[samp_index] + ntsc_decoded[samp_index+3] ) / 2;
805884      int g = ( ntsc_decoded[samp_index+1] + ntsc_decoded[samp_index+4] ) / 2;
806885      int b = ( ntsc_decoded[samp_index+2] + ntsc_decoded[samp_index+5] ) / 2;
r2547r2548
818897  cga fetches 2 byte per mc6845 access.
819898***************************************************************************/
820899
821static MC6845_UPDATE_ROW( cga_gfx_2bpp_update_row ) {
900static MC6845_UPDATE_ROW( cga_gfx_2bpp_update_row )
901{
822902   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
823903   int i;
824904
825905   if ( y == 0 ) CGA_LOG(1,"cga_gfx_2bpp_update_row",("\n"));
826   for ( i = 0; i < x_count; i++ ) {
906   for ( i = 0; i < x_count; i++ )
907   {
827908      UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 );
828909      UINT8 data = videoram[ offset ];
829910
r2547r2548
849930  Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000
850931***************************************************************************/
851932
852static MC6845_UPDATE_ROW( cga_gfx_1bpp_update_row ) {
933static MC6845_UPDATE_ROW( cga_gfx_1bpp_update_row )
934{
853935   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
854936   UINT8   fg = cga.color_select & 0x0F;
855937   int i;
856938
857939   if ( y == 0 ) CGA_LOG(1,"cga_gfx_1bpp_update_row",("\n"));
858   for ( i = 0; i < x_count; i++ ) {
940   for ( i = 0; i < x_count; i++ )
941   {
859942      UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( ra & 1 ) << 13 );
860943      UINT8 data = videoram[ offset ];
861944
r2547r2548
882965}
883966
884967
885static MC6845_UPDATE_ROW( cga_update_row ) {
886   if ( cga.update_row ) {
968static MC6845_UPDATE_ROW( cga_update_row )
969{
970   if ( cga.update_row )
971   {
887972      cga.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
888973   }
889974}
890975
891976
892static MC6845_ON_HSYNC_CHANGED( cga_hsync_changed ) {
977static MC6845_ON_HSYNC_CHANGED( cga_hsync_changed )
978{
893979   cga.hsync = hsync ? 1 : 0;
894980}
895981
896982
897static MC6845_ON_VSYNC_CHANGED( cga_vsync_changed ) {
983static MC6845_ON_VSYNC_CHANGED( cga_vsync_changed )
984{
898985   cga.vsync = vsync ? 8 : 0;
899   if ( vsync ) {
986   if ( vsync )
987   {
900988      cga.frame++;
901989   }
902990}
903991
904992
905static void pc_cga_set_palette_luts(void) {
993static void pc_cga_set_palette_luts(void)
994{
906995   /* Setup 2bpp palette lookup table */
907   if ( cga.mode_control & 0x10 ) {
996   if ( cga.mode_control & 0x10 )
997   {
908998      cga.palette_lut_2bpp[0] = 0;
909   } else {
999   }
1000   else
1001   {
9101002      cga.palette_lut_2bpp[0] = cga.color_select & 0x0F;
9111003   }
912   if ( cga.mode_control & 0x04 ) {
1004   if ( cga.mode_control & 0x04 )
1005   {
9131006      cga.palette_lut_2bpp[1] = ( ( cga.color_select & 0x10 ) >> 1 ) | 3;
9141007      cga.palette_lut_2bpp[2] = ( ( cga.color_select & 0x10 ) >> 1 ) | 4;
9151008      cga.palette_lut_2bpp[3] = ( ( cga.color_select & 0x10 ) >> 1 ) | 7;
916   } else {
917      if ( cga.color_select & 0x20 ) {
1009   }
1010   else
1011   {
1012      if ( cga.color_select & 0x20 )
1013      {
9181014         cga.palette_lut_2bpp[1] = ( ( cga.color_select & 0x10 ) >> 1 ) | 3;
9191015         cga.palette_lut_2bpp[2] = ( ( cga.color_select & 0x10 ) >> 1 ) | 5;
9201016         cga.palette_lut_2bpp[3] = ( ( cga.color_select & 0x10 ) >> 1 ) | 7;
921      } else {
1017      }
1018      else
1019      {
9221020         cga.palette_lut_2bpp[1] = ( ( cga.color_select & 0x10 ) >> 1 ) | 2;
9231021         cga.palette_lut_2bpp[2] = ( ( cga.color_select & 0x10 ) >> 1 ) | 4;
9241022         cga.palette_lut_2bpp[3] = ( ( cga.color_select & 0x10 ) >> 1 ) | 6;
r2547r2548
9571055   cga.mode_control = data;
9581056
9591057   //logerror("mode set to %02X\n", cga.mode_control & 0x3F );
960   switch ( cga.mode_control & 0x3F ) {
1058   switch ( cga.mode_control & 0x3F )
1059   {
9611060   case 0x08: case 0x09: case 0x0C: case 0x0D:
9621061      mc6845_set_hpixels_per_column( devconf, 8 );
963      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) {
964         if ( cga.mode_control & 0x04 ) {
1062      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE )
1063      {
1064         if ( cga.mode_control & 0x04 )
1065         {
9651066            /* Composite greyscale */
9661067            cga.update_row = cga_text_inten_comp_grey_update_row;
967         } else {
1068         }
1069         else
1070         {
9681071            /* Composite colour */
9691072            cga.update_row = cga_text_inten_update_row;
9701073         }
971      } else {
1074      }
1075      else
1076      {
9721077         /* RGB colour */
9731078         cga.update_row = cga_text_inten_update_row;
9741079      }
9751080      break;
9761081   case 0x0A: case 0x0B: case 0x2A: case 0x2B:
9771082      mc6845_set_hpixels_per_column( devconf, 8 );
978      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) {
1083      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE )
1084      {
9791085         cga.update_row = cga_gfx_4bppl_update_row;
980      } else {
1086      }
1087      else
1088      {
9811089         cga.update_row = cga_gfx_2bpp_update_row;
9821090      }
9831091      break;
r2547r2548
9911099      break;
9921100   case 0x1A: case 0x1B: case 0x3A: case 0x3B:
9931101      mc6845_set_hpixels_per_column( devconf, 16 );
994      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) {
1102      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE )
1103      {
9951104         cga.update_row = cga_gfx_4bpph_update_row;
996      } else {
1105      }
1106      else
1107      {
9971108         cga.update_row = cga_gfx_1bpp_update_row;
9981109      }
9991110      break;
r2547r2548
10031114      break;
10041115   case 0x28: case 0x29: case 0x2C: case 0x2D:
10051116      mc6845_set_hpixels_per_column( devconf, 8 );
1006      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) {
1007         if ( cga.mode_control & 0x04 ) {
1117      if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE )
1118      {
1119         if ( cga.mode_control & 0x04 )
1120         {
10081121            /* Composite greyscale */
10091122            cga.update_row = cga_text_blink_update_row;
1010         } else {
1123         }
1124         else
1125         {
10111126            /* Composite colour */
10121127            cga.update_row = cga_text_blink_update_row;
10131128         }
1014      } else {
1129      }
1130      else
1131      {
10151132         /* RGB colour */
10161133         cga.update_row = cga_text_blink_update_row;
10171134      }
r2547r2548
13161433static const int videoram_offset[4]= { 0x0000, 0x4000, 0x8000, 0xC000 };
13171434
13181435
1319static const UINT8 mc6845_writeonce_register[31] = {
1436static const UINT8 mc6845_writeonce_register[31] =
1437{
13201438   1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
13211439};
13221440
r2547r2548
13301448} pc1512;
13311449
13321450
1333static MC6845_UPDATE_ROW( pc1512_gfx_4bpp_update_row ) {
1451static MC6845_UPDATE_ROW( pc1512_gfx_4bpp_update_row )
1452{
13341453   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
13351454   UINT16   offset_base = ra << 13;
13361455   int i;
13371456
13381457   if ( y == 0 ) CGA_LOG(1,"pc1512_gfx_4bpp_update_row",("\n"));
1339   for ( i = 0; i < x_count; i++ ) {
1458   for ( i = 0; i < x_count; i++ )
1459   {
13401460      UINT16 offset = offset_base | ( ( ma + i ) & 0x1FFF );
13411461      UINT16 i = ( cga.color_select & 8 ) ? videoram[ videoram_offset[3] | offset ] << 3 : 0;
13421462      UINT16 r = ( cga.color_select & 4 ) ? videoram[ videoram_offset[2] | offset ] << 2 : 0;
r2547r2548
13591479{
13601480   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, CGA_MC6845_NAME);
13611481
1362   switch (offset) {
1482   switch (offset)
1483   {
13631484   case 0: case 2: case 4: case 6:
13641485      data &= 0x1F;
13651486      mc6845_address_w( devconf, offset, data );
r2547r2548
13671488      break;
13681489
13691490   case 1: case 3: case 5: case 7:
1370      if ( ! pc1512.mc6845_locked_register[pc1512.mc6845_address] ) {
1491      if ( ! pc1512.mc6845_locked_register[pc1512.mc6845_address] )
1492      {
13711493         mc6845_register_w( devconf, offset, data );
1372         if ( mc6845_writeonce_register[pc1512.mc6845_address] ) {
1494         if ( mc6845_writeonce_register[pc1512.mc6845_address] )
1495         {
13731496            pc1512.mc6845_locked_register[pc1512.mc6845_address] = 1;
13741497         }
13751498      }
r2547r2548
13771500
13781501   case 0x8:
13791502      /* Check if we're changing to graphics mode 2 */
1380      if ( ( cga.mode_control & 0x12 ) != 0x12 && ( data & 0x12 ) == 0x12 ) {
1503      if ( ( cga.mode_control & 0x12 ) != 0x12 && ( data & 0x12 ) == 0x12 )
1504      {
13811505         pc1512.write = 0x0F;
1382      } else {
1506      }
1507      else
1508      {
13831509         memory_set_bankptr(1, videoram + videoram_offset[0]);
13841510      }
13851511      cga.mode_control = data;
1386      switch( cga.mode_control & 0x3F ) {
1512      switch( cga.mode_control & 0x3F )
1513      {
13871514      case 0x08: case 0x09: case 0x0C: case 0x0D:
13881515         mc6845_set_hpixels_per_column( devconf, 8 );
13891516         cga.update_row = cga_text_inten_update_row;
13901517         break;
13911518      case 0x0A: case 0x0B: case 0x2A: case 0x2B:
13921519         mc6845_set_hpixels_per_column( devconf, 8 );
1393         if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) {
1520         if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE )
1521         {
13941522            cga.update_row = cga_gfx_4bppl_update_row;
1395         } else {
1523         }
1524         else
1525         {
13961526            cga.update_row = cga_gfx_2bpp_update_row;
13971527         }
13981528         break;
r2547r2548
14321562
14331563   case 0xe:
14341564      pc1512.read = data;
1435      if ( ( cga.mode_control & 0x12 ) == 0x12 ) {
1565      if ( ( cga.mode_control & 0x12 ) == 0x12 )
1566      {
14361567         memory_set_bankptr(1, videoram + videoram_offset[data & 3]);
14371568      }
14381569      break;
r2547r2548
14471578{
14481579   UINT8 data;
14491580
1450   switch (offset) {
1581   switch (offset)
1582   {
14511583   case 0xd:
14521584      data = pc1512.write;
14531585      break;
r2547r2548
14661598
14671599static WRITE8_HANDLER ( pc1512_videoram_w )
14681600{
1469   if ( ( cga.mode_control & 0x12 ) == 0x12 ) {
1601   if ( ( cga.mode_control & 0x12 ) == 0x12 )
1602   {
14701603      if (pc1512.write & 1)
14711604         videoram[offset+videoram_offset[0]] = data; /* blue plane */
14721605      if (pc1512.write & 2)
r2547r2548
14751608         videoram[offset+videoram_offset[2]] = data; /* red */
14761609      if (pc1512.write & 8)
14771610         videoram[offset+videoram_offset[3]] = data; /* intensity (text, 4color) */
1478   } else {
1611   }
1612   else
1613   {
14791614      videoram[offset + videoram_offset[0]] = data;
14801615   }
14811616}
r2547r2548
15101645   mc6845_update( devconf, bitmap, cliprect);
15111646
15121647   /* Check for changes in font dipsetting */
1513   switch ( CGA_FONT & 0x03 ) {
1648   switch ( CGA_FONT & 0x03 )
1649   {
15141650   case 0:
15151651      cga.chr_gen = memory_region(REGION_GFX1) + 0x0000;
15161652      break;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team