Previous 15994 Revisions Next

r3850 Tuesday 16th December, 2008 at 20:27:40 UTC by Wilbert Pol
Added vblank signalling to the EGA implementation.
[src/mess/video]crtc_ega.c crtc_ega.h pc_ega.c

src/mess/video/crtc_ega.c
r3849r3850
8181   emu_timer *hsync_off_timer;
8282   emu_timer *vsync_on_timer;
8383   emu_timer *vsync_off_timer;
84   emu_timer *vblank_on_timer;
85   emu_timer *vblank_off_timer;
8486   emu_timer *light_pen_latch_timer;
8587
8688   /* computed values - do NOT state save these! */
r3849r3850
104106static void update_de_changed_timer(crtc_ega_t *crtc_ega);
105107static void update_hsync_changed_timers(crtc_ega_t *crtc_ega);
106108static void update_vsync_changed_timers(crtc_ega_t *crtc_ega);
109static void update_vblank_changed_timers(crtc_ega_t *crtc_ega);
107110
108111
109112/* makes sure that the passed in device is the right type */
r3849r3850
306309         update_de_changed_timer(crtc_ega);
307310         update_hsync_changed_timers(crtc_ega);
308311         update_vsync_changed_timers(crtc_ega);
312         update_vblank_changed_timers(crtc_ega);
309313      }
310314   }
311315}
r3849r3850
401405}
402406
403407
408static void update_vblank_changed_timers(crtc_ega_t *crtc_ega)
409{
410   if (crtc_ega->has_valid_parameters && (crtc_ega->vblank_on_timer != NULL))
411   {
412      timer_adjust_oneshot(crtc_ega->vblank_on_timer,  video_screen_get_time_until_pos(crtc_ega->screen, crtc_ega->vert_disp_end,  crtc_ega->hsync_on_pos), 0);
413      timer_adjust_oneshot(crtc_ega->vblank_off_timer, video_screen_get_time_until_pos(crtc_ega->screen, 0, crtc_ega->hsync_off_pos), 0);
414   }
415}
416
417
404418static TIMER_CALLBACK( de_changed_timer_cb )
405419{
406420   const device_config *device = ptr;
r3849r3850
457471}
458472
459473
474static TIMER_CALLBACK( vblank_on_timer_cb )
475{
476   const device_config *device = ptr;
477   crtc_ega_t *crtc_ega = get_safe_token(device);
460478
479   /* call the callback function -- we know it exists */
480   crtc_ega->intf->on_vblank_changed(device, TRUE);
481
482   update_vblank_changed_timers(crtc_ega);
483}
484
485
486static TIMER_CALLBACK( vblank_off_timer_cb )
487{
488   const device_config *device = ptr;
489   crtc_ega_t *crtc_ega = get_safe_token(device);
490
491   /* call the callback function -- we know it exists */
492   crtc_ega->intf->on_vblank_changed(device, FALSE);
493
494   update_vblank_changed_timers(crtc_ega);
495}
496
497
498
461499UINT16 crtc_ega_get_ma(const device_config *device)
462500{
463501   UINT16 ret;
r3849r3850
718756         crtc_ega->vsync_on_timer = timer_alloc(device->machine, vsync_on_timer_cb, (void *)device);
719757         crtc_ega->vsync_off_timer = timer_alloc(device->machine, vsync_off_timer_cb, (void *)device);
720758      }
759
760      if (crtc_ega->intf->on_vblank_changed != NULL)
761      {
762         crtc_ega->vblank_on_timer = timer_alloc(device->machine, vblank_on_timer_cb, (void *)device);
763         crtc_ega->vblank_off_timer = timer_alloc(device->machine, vblank_off_timer_cb, (void *)device);
764      }
721765   }
722766
723767   crtc_ega->light_pen_latch_timer = timer_alloc(device->machine, light_pen_latch_timer_cb, (void *)device);
src/mess/video/crtc_ega.h
r3849r3850
3434typedef void (*crtc_ega_on_vsync_changed_func)(const device_config *device, int vsync);
3535#define CRTC_EGA_ON_VSYNC_CHANGED(name)   void name(const device_config *device, int vsync)
3636
37typedef void (*crtc_ega_on_vblank_changed_func)(const device_config *device, int vblank);
38#define CRTC_EGA_ON_VBLANK_CHANGED(name) void name(const device_config *device, int vblank)
3739
40
3841/* interface */
3942typedef struct _crtc_ega_interface crtc_ega_interface;
4043struct _crtc_ega_interface
4144{
4245   const char *screen_tag;      /* screen we are acting on */
43   int clock;               /* the clock (pin 21) of the chip */
46   int clock;               /* the clock of the chip */
4447   int hpixels_per_column;      /* number of pixels per video memory address */
4548
4649   /* if specified, this gets called before any pixel update,
r3849r3850
5760   /* if specified, this gets called after all row updating is complete */
5861   crtc_ega_end_update_func         end_update;
5962
60   /* if specified, this gets called for every change of the disply enable pin (pin 18) */
63   /* if specified, this gets called for every change of the disply enable signal */
6164   crtc_ega_on_de_changed_func      on_de_changed;
6265
63   /* if specified, this gets called for every change of the HSYNC pin (pin 39) */
66   /* if specified, this gets called for every change of the HSYNC signal */
6467   crtc_ega_on_hsync_changed_func   on_hsync_changed;
6568
66   /* if specified, this gets called for every change of the VSYNC pin (pin 40) */
69   /* if specified, this gets called for every change of the VSYNC signal */
6770   crtc_ega_on_vsync_changed_func   on_vsync_changed;
71
72   /* if specificed, this gets called for every change of the VBLANK signal */
73   crtc_ega_on_vblank_changed_func   on_vblank_changed;
6874};
6975
7076
src/mess/video/pc_ega.c
r3849r3850
5555                           1 = video is being displayed
5656
5757
58   Configuration switches
59   SW1 SW2 SW3 SW4
60   OFF OFF OFF ON  - EGA, Color 80x25 (5153)
61                   - EGA (primary) + MDA, Color 80x25 + Monochrome
62   OFF OFF ON  OFF   - EGA, Monochrome (5151)
63                   - EGA (primary) + CGA, Monochrome + Color 80x25
64   OFF OFF ON  ON  - EGA + MDA (primary), 5154 + Enhanced Monochrome
65   OFF ON  OFF ON  - EGA + CGA (primary), Monochrome + Color 80x25
66   OFF ON  ON  OFF - EGA, Enhanced Color - Enhanced Mode (5154)
67                   - EGA (primary) + MDA, 5154 monitor + Enhanced Monochrome
68   OFF ON  ON  ON  - EGA + MDA (primary), Color 80x25 + Monochrome
69   ON  OFF OFF ON  - EGA, Color 40x25 (5153)
70                   - EGA (primary) + MDA, Color 40x25 + Monochrome
71   ON  OFF ON  OFF - EGA (primary) + CGA, Monochrome + Color 40x25
72   ON  OFF ON  ON  - EGA + MDA (primary), 5154 + Normal Monochrome
73   ON  ON  OFF ON  - EGA + CGA (primary), Monochrome + Color 40x25
74   ON  ON  ON  OFF - EGA, Enhanced Color - Enhanced Mode (5154)
75                   - EGA (primary) + MDA, 5154 monitor + Normal Monochrome
76   ON  ON  ON  ON  - EGA + MDA (primary), Color 40x25 + Monochrome
77
78
5879   3XA - 7 6 5 4 3 2 1 0 - Feature Control Register - Write Only
5980         | | | | | | | |
6081         | | | | | | | +-- output to FEAT0 of the feature connector
r3849r3850
7798         | | | | | +------ light pen switch
7899         | | | | |         0 = switch is closed
79100         | | | | |         1 = switch is open
80         | | | | +-------- vertical retrace
101         | | | | +-------- vertical blank
81102         | | | |           0 = video information is being displayed
82         | | | |           1 = CRT is in vertical retrace
103         | | | |           1 = CRT is in vertical blank
83104         | | | +---------- diagnostic usage
84105         | | +------------ diagnostic usage
85106         | +-------------- reserved/unused
86107         +---------------- reserved/unused
87108
109We think bits 4 and 5 of the status register contain some information about the
110current pixel that is being drawn. Those bits do not seem to be documented.
88111
112
89113The EGA graphics card introduces a lot of new indexed registers to handle the
90114enhanced graphics. These new indexed registers can be divided into three
91115groups:
r3849r3850
461485
462486   UINT8   frame_cnt;
463487   UINT8   vsync;
488   UINT8   vblank;
464489   UINT8   display_enable;
465490} ega;
466491
r3849r3850
474499static CRTC_EGA_UPDATE_ROW( ega_update_row );
475500static CRTC_EGA_ON_DE_CHANGED( ega_de_changed );
476501static CRTC_EGA_ON_VSYNC_CHANGED( ega_vsync_changed );
502static CRTC_EGA_ON_VBLANK_CHANGED( ega_vblank_changed );
477503static READ8_HANDLER( pc_ega8_3b0_r );
478504static WRITE8_HANDLER( pc_ega8_3b0_w );
479505static READ16_HANDLER( pc_ega16le_3b0_r );
r3849r3850
507533   NULL,            /* end_update */
508534   ega_de_changed,      /* on_de_chaged */
509535   NULL,            /* on_hsync_changed */
510   ega_vsync_changed   /* on_vsync_changed */
536   ega_vsync_changed,   /* on_vsync_changed */
537   ega_vblank_changed   /* on_vblank_changed */
511538};
512539
513540
r3849r3850
694721}
695722
696723
724static CRTC_EGA_ON_VBLANK_CHANGED( ega_vblank_changed )
725{
726   ega.vblank = vblank ? 8 : 0;
727}
728
729
697730static CRTC_EGA_UPDATE_ROW( pc_ega_graphics )
698731{
699732   UINT16   *p = BITMAP_ADDR16(bitmap, y, 0);
700733   int   i;
701734
735//   logerror( "pc_ega_graphics: y = %d, x_count = %d, ma = %d, ra = %d\n", y, x_count, ma, ra );
736
702737   for ( i = 0; i < x_count; i++ )
703738   {
704739      *p = 0;
r3849r3850
788823   }
789824   crtc_ega_set_clock( device, clock / pixels );
790825   crtc_ega_set_hpixels_per_column( device, pixels );
826
827if ( ! ega.update_row )
828   logerror("unknown video mode\n");
791829}
792830
793831
r3849r3850
814852
815853   /* Input Status Register 1 */
816854   case 10:
817      data = ega.vsync | ega.display_enable;
855      data = ega.vblank | ega.display_enable;
818856
857      if ( ega.display_enable )
858      {
859         /* For the moment i'm putting in some bogus data */
860         static int pixel_data;
861
862         pixel_data = ( pixel_data + 1 ) & 0x03;
863         data |= ( pixel_data << 4 );
864      }
865
819866      /* Reset the attirubte writing flip flop to let the next write go to the index reigster */
820867      ega.attribute.index_write = 1;
821868      break;
r3849r3850
892939
893940static READ8_HANDLER( pc_ega8_3c0_r )
894941{
942   UINT8   dips = 0x08;   /* 0x01 - EGA only, 80x25 color(?) */
943/*
9440000 - 40x25
9450001 - no display (text at a0000) and writes to 0c00xx (?), seems to be a graphics mode
9460010 - 40x25
9470011 - no display
9480100 - 40x25
9490101 - no display
9500110 - 40x25
9510111 - no display
9521000 - 40x25
9531001 - no diplsay (text at a0000)
9541010 - 40x25
9551100 - 40x25
9561110 - 40x25
957*/
895958   int data = 0xff;
896959
897960   if ( VERBOSE_EGA )
r3849r3850
907970
908971   /* Feature Read */
909972   case 2:
910      data = ( data & 0x0F );
973      data = ( data & 0x0f );
911974      data |= ( ( ega.feature_control & 0x03 ) << 5 );
912975      data |= ( ega.vsync ? 0x00 : 0x80 );
976      data |= ( ( ( dips >> ( ( ( ega.misc_output & 0xc0 ) >> 6 ) ) ) & 0x01 ) << 4 );
913977      break;
914978
915979   /* Sequencer */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team