Previous 15994 Revisions Next

r15503 Monday 25th June, 2012 at 18:27:10 UTC by Wilbert Pol
isa_ega.c/crtc_ega.c: Changed crtc_ega to a C++ device. Fix vblank signal timing, fixing EGA bios timing checks for all dipswitch settings.
[src/mess/video]crtc_ega.c crtc_ega.h isa_ega.c isa_ega.h

src/mess/video/isa_ega.c
r15502r15503
454454*/
455455static SCREEN_UPDATE_IND16( pc_ega );
456456static CRTC_EGA_UPDATE_ROW( ega_update_row );
457static CRTC_EGA_ON_DE_CHANGED( ega_de_changed );
458static CRTC_EGA_ON_VSYNC_CHANGED( ega_vsync_changed );
459static CRTC_EGA_ON_VBLANK_CHANGED( ega_vblank_changed );
460457
461static const crtc_ega_interface crtc_ega_ega_intf =
458static CRTC_EGA_INTERFACE( crtc_ega_ega_intf )
462459{
463460   EGA_SCREEN_NAME,   /* screen number */
464461   8,               /* numbers of pixels per video memory address */
465462   NULL,            /* begin_update */
466463   ega_update_row,      /* update_row */
467464   NULL,            /* end_update */
468   ega_de_changed,      /* on_de_chaged */
469   NULL,            /* on_hsync_changed */
470   ega_vsync_changed,   /* on_vsync_changed */
471   ega_vblank_changed   /* on_vblank_changed */
465   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, de_changed),      /* on_de_chaged */
466   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, hsync_changed),   /* on_hsync_changed */
467   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, vsync_changed),   /* on vsync_changed */
468   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, vblank_changed)   /* on_vblank_changed */
472469};
473470
474471
r15502r15503
510507
511508INPUT_PORTS_START( ega )
512509   PORT_START( "config" )
513   PORT_CONFNAME( 0x0f, 0x0e, "dipswitches" )
514   PORT_CONFSETTING( 0x00, "0000 - MDA PRIMARY, EGA COLOR, 40x25" )
515   PORT_CONFSETTING( 0x08, "0001 - MDA PRIMARY, EGA COLOR, 80x25" )
516   PORT_CONFSETTING( 0x04, "0010 - MDA PRIMARY, EGA HI RES EMULATE (SAME AS 0001)" )
517   PORT_CONFSETTING( 0x0c, "0011 - MDA PRIMARY, EGA HI RES ENHANCED" )
518   PORT_CONFSETTING( 0x02, "0100 - CGA 40 PRIMARY, EGA MONOCHROME" )
519   PORT_CONFSETTING( 0x0a, "0101 - CGA 80 PRIMARY, EGA MONOCHROME" )
520   PORT_CONFSETTING( 0x06, "0110 - MDA SECONDARY, EGA COLOR, 40x25" )
521   PORT_CONFSETTING( 0x0e, "0111 - MDA SECONDARY, EGA COLOR, 80x25" )
522   PORT_CONFSETTING( 0x01, "1000 - MDA SECONDARY, EGA HI RES EMULATE (SAME AS 0111)" )
523   PORT_CONFSETTING( 0x09, "1001 - MDA SECONDARY, EGA HI RES ENHANCED" )
524   PORT_CONFSETTING( 0x05, "1010 - COLOR 40 SECONDARY, EGA" )
525   PORT_CONFSETTING( 0x0d, "1011 - COLOR 80 SECONDARY, EGA" )
526   PORT_CONFSETTING( 0x03, "1100 - RESERVED" )
527   PORT_CONFSETTING( 0x0b, "1101 - RESERVED" )
528   PORT_CONFSETTING( 0x07, "1110 - RESERVED" )
529   PORT_CONFSETTING( 0x0f, "1111 - RESERVED" )
510   PORT_CONFNAME( 0x0f, 0x09, "dipswitches" )
511   PORT_CONFSETTING( 0x00, "0000 - MDA PRIMARY, EGA COLOR, 40x25" )                     /* DIAG: ?? 40 cols, RGBI */
512   PORT_CONFSETTING( 0x08, "0001 - MDA PRIMARY, EGA COLOR, 80x25" )                     /* DIAG: ?? 80 cols, RGBI */
513   PORT_CONFSETTING( 0x04, "0010 - MDA PRIMARY, EGA HI RES EMULATE (SAME AS 0001)" )         /* DIAG: ?? 80 cols, RGBI */
514   PORT_CONFSETTING( 0x0c, "0011 - MDA PRIMARY, EGA HI RES ENHANCED" )                     /* DIAG: Color Display 40 cols, RrGgBb */
515   PORT_CONFSETTING( 0x02, "0100 - CGA 40 PRIMARY, EGA MONOCHROME" )                     /* DIAG: ??, Mono RGBI */
516   PORT_CONFSETTING( 0x0a, "0101 - CGA 80 PRIMARY, EGA MONOCHROME" )                     /* DIAG: ??, Mono RGBI */
517   PORT_CONFSETTING( 0x06, "0110 - MDA SECONDARY, EGA COLOR, 40x25" )                     /* DIAG: Color Display 40 cols, RGBI */
518   PORT_CONFSETTING( 0x0e, "0111 - MDA SECONDARY, EGA COLOR, 80x25" )                     /* DIAG: Color Display 80 cols, RGBI */
519   PORT_CONFSETTING( 0x01, "1000 - MDA SECONDARY, EGA HI RES EMULATE (SAME AS 0111)" )         /* DIAG: Color Display 80 cols, RGBI */
520   PORT_CONFSETTING( 0x09, "1001 - MDA SECONDARY, EGA HI RES ENHANCED" )                  /* DIAG: Color Display 40 cols, RrGgBb */
521   PORT_CONFSETTING( 0x05, "1010 - COLOR 40 SECONDARY, EGA" )                           /* DIAG: Monochrome display, Mono RGBI */
522   PORT_CONFSETTING( 0x0d, "1011 - COLOR 80 SECONDARY, EGA" )                           /* DIAG: Monochrome display, Mono RGBI */
523   PORT_CONFSETTING( 0x03, "1100 - RESERVED" )                                       /* ??, RGBI */
524   PORT_CONFSETTING( 0x0b, "1101 - RESERVED" )                                       /* ??, RGBI */
525   PORT_CONFSETTING( 0x07, "1110 - RESERVED" )                                       /* ??, RGBI */
526   PORT_CONFSETTING( 0x0f, "1111 - RESERVED" )                                       /* ??, RGBI */
530527INPUT_PORTS_END
531528
532529//**************************************************************************
r15502r15503
618615   m_plane[2] = m_videoram + 0x20000;
619616   m_plane[3] = m_videoram + 0x30000;
620617
621   m_crtc_ega = subdevice(EGA_CRTC_NAME);
618   m_crtc_ega = subdevice<crtc_ega_device>(EGA_CRTC_NAME);
622619
623620   m_isa->install_rom(this, 0xc0000, 0xc3fff, 0, 0, "ega", "user2");
624621   m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate(FUNC(isa8_ega_device::pc_ega8_3b0_r), this), write8_delegate(FUNC(isa8_ega_device::pc_ega8_3b0_w), this));
r15502r15503
639636   memset(&m_graphics_controller,0,sizeof(m_graphics_controller));
640637
641638   m_frame_cnt = 0;
639   m_hsync = 0;
642640   m_vsync = 0;
643641   m_vblank = 0;
644642   m_display_enable = 0;
r15502r15503
730728static SCREEN_UPDATE_IND16( pc_ega )
731729{
732730   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(screen.owner());
733   crtc_ega_update( ega->m_crtc_ega, bitmap, cliprect);
731   ega->m_crtc_ega->screen_update( screen, bitmap, cliprect);
734732   return 0;
735733}
736734
r15502r15503
745743}
746744
747745
748static CRTC_EGA_ON_DE_CHANGED( ega_de_changed )
746WRITE_LINE_MEMBER( isa8_ega_device::de_changed )
749747{
750   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner());
751   ega->m_display_enable = display_enabled ? 1 : 0;
748   m_display_enable = state ? 1 : 0;
752749}
753750
754751
755static CRTC_EGA_ON_VSYNC_CHANGED( ega_vsync_changed )
752WRITE_LINE_MEMBER( isa8_ega_device::hsync_changed )
756753{
757   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner());
758   ega->m_vsync = vsync ? 8 : 0;
759   if ( vsync )
754   m_hsync = state ? 1 : 0;
755}
756
757
758WRITE_LINE_MEMBER( isa8_ega_device::vsync_changed )
759{
760   m_vsync = state ? 1 : 0;
761   if ( state )
760762   {
761      ega->m_frame_cnt++;
763      m_frame_cnt++;
762764   }
763765}
764766
765767
766static CRTC_EGA_ON_VBLANK_CHANGED( ega_vblank_changed )
768WRITE_LINE_MEMBER( isa8_ega_device::vblank_changed )
767769{
768   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner());
769   ega->m_vblank = vblank ? 8 : 0;
770   m_vblank = state ? 8 : 0;
770771}
771772
772773
r15502r15503
803804   {
804805      // EGA mode
805806
806//      UINT8 mask = ega->m_attribute.data[0x12] & 0x0f;
807      UINT8 mask = ega->m_attribute.data[0x12] & 0x0f;
807808
808809      for ( int i = 0; i < x_count; i++ )
809810      {
r15502r15503
817818         {
818819            UINT16 col = ( data0 & 0x01 ) | ( data1 & 0x02 ) | ( data2 & 0x04 ) | ( data3 & 0x08 );
819820
820//              col &= mask;
821            col &= mask;
821822
822823            p[j] = ega->m_attribute.data[col];
823824
r15502r15503
942943   {
943944      clock >>= 1;
944945   }
945   crtc_ega_set_clock( m_crtc_ega, clock / pixels );
946   crtc_ega_set_hpixels_per_column( m_crtc_ega, pixels );
946   m_crtc_ega->set_clock( clock / pixels );
947   m_crtc_ega->set_hpixels_per_column( pixels );
947948
948949if ( ! m_update_row )
949950   logerror("unknown video mode\n");
r15502r15503
954955{
955956   UINT8 data = 0xFF;
956957
957   if ( !space.debugger_access() )
958   if ( !space.debugger_access() && ! ( m_sequencer.data[4] & 0x04 ) )
958959   {
959960      /* Fill read latches */
960961      m_read_latch[0] = m_plane[0][offset & 0xffff];
r15502r15503
967968   {
968969      // Read mode #1
969970      popmessage("ega: Read mode 1 not supported yet!");
971      printf("EGA: Read mode 1 not supported yet!\n");
970972   }
971973   else
972974   {
r15502r15503
987989}
988990
989991
992UINT8 isa8_ega_device::alu_op( UINT8 data, UINT8 latch_data )
993{
994   UINT8 mask = m_graphics_controller.data[8];
995
996   switch( m_graphics_controller.data[3] & 0x18 )
997   {
998   case 0x00:      // Unmodified
999      return ( data & mask ) | ( latch_data & ~mask );
1000
1001   case 0x08:      // AND
1002      return ( data | ~mask ) & latch_data;
1003
1004   case 0x10:      // OR
1005      return ( data & mask ) | latch_data;
1006
1007   case 0x18:      // XOR
1008      return ( data & mask ) ^ latch_data;
1009   }
1010   return 0;
1011}
1012
1013
9901014WRITE8_MEMBER( isa8_ega_device::write )
9911015{
1016   UINT8 d[4];
9921017   UINT8 alu[4];
9931018   UINT8 target_mask = m_graphics_controller.data[8];
9941019
r15502r15503
10001025      // Pass through barrel shifter
10011026      data = ( ( ( data << 8 ) | data ) >> ( m_graphics_controller.data[3] & 0x07 ) ) & 0xFF;
10021027
1003      // Pass through ALUs
1004      switch( m_graphics_controller.data[3] & 0x18 )
1028      d[0] = d[1] = d[2] = d[3] = data;
1029
1030      /* Apply Set/Reset settings */
1031      if ( m_graphics_controller.data[1] & 0x01 )
10051032      {
1006      case 0x00:      // Unmodified
1007         alu[0] = data;
1008         alu[1] = data;
1009         alu[2] = data;
1010         alu[3] = data;
1011         break;
1033         d[0] = ( m_graphics_controller.data[0] & 0x01 ) ? 0xff : 0x00;
1034      }
1035      if ( m_graphics_controller.data[1] & 0x02 )
1036      {
1037         d[1] = ( m_graphics_controller.data[0] & 0x02 ) ? 0xff : 0x00;
1038      }
1039      if ( m_graphics_controller.data[1] & 0x04 )
1040      {
1041         d[2] = ( m_graphics_controller.data[0] & 0x04 ) ? 0xff : 0x00;
1042      }
1043      if ( m_graphics_controller.data[1] & 0x08 )
1044      {
1045         d[3] = ( m_graphics_controller.data[0] & 0x08 ) ? 0xff : 0x00;
1046      }
10121047
1013      case 0x08:      // AND
1014         alu[0] = m_read_latch[0] & data;
1015         alu[1] = m_read_latch[1] & data;
1016         alu[2] = m_read_latch[2] & data;
1017         alu[3] = m_read_latch[3] & data;
1018         break;
1048      // Pass through ALUs
1049      alu[0] = alu_op( d[0], m_read_latch[0] );
1050      alu[1] = alu_op( d[1], m_read_latch[1] );
1051      alu[2] = alu_op( d[2], m_read_latch[2] );
1052      alu[3] = alu_op( d[3], m_read_latch[3] );
10191053
1020      case 0x10:      // OR
1021         alu[0] = m_read_latch[0] | data;
1022         alu[1] = m_read_latch[1] | data;
1023         alu[2] = m_read_latch[2] | data;
1024         alu[3] = m_read_latch[3] | data;
1025         break;
1026
1027      case 0x18:      // XOR
1028         alu[0] = m_read_latch[0] ^ data;
1029         alu[1] = m_read_latch[1] ^ data;
1030         alu[2] = m_read_latch[2] ^ data;
1031         alu[3] = m_read_latch[3] ^ data;
1032         break;
1033      }
10341054      break;
10351055
10361056   case 1:      // Write mode 1
r15502r15503
10421062      return;
10431063
10441064   case 2:      // Write mode 2
1045      alu[0] = ( data & 0x01 ) ? 0xff : 0x00;
1046      alu[1] = ( data & 0x02 ) ? 0xff : 0x00;
1047      alu[2] = ( data & 0x04 ) ? 0xff : 0x00;
1048      alu[3] = ( data & 0x08 ) ? 0xff : 0x00;
1065      d[0] = ( data & 0x01 ) ? 0xff : 0x00;
1066      d[1] = ( data & 0x02 ) ? 0xff : 0x00;
1067      d[2] = ( data & 0x04 ) ? 0xff : 0x00;
1068      d[3] = ( data & 0x08 ) ? 0xff : 0x00;
1069
1070      alu[0] = alu_op( d[0], m_read_latch[0] );
1071      alu[1] = alu_op( d[1], m_read_latch[1] );
1072      alu[2] = alu_op( d[2], m_read_latch[2] );
1073      alu[3] = alu_op( d[3], m_read_latch[3] );
10491074      break;
10501075
10511076   case 3:      // Write mode 3
r15502r15503
11321157}
11331158
11341159
1135UINT8 isa8_ega_device::pc_ega8_3X0_r(UINT8 offset)
1160READ8_MEMBER( isa8_ega_device::pc_ega8_3X0_r )
11361161{
11371162   int data = 0xff;
11381163
1139   if ( VERBOSE_EGA )
1140   {
1141      logerror("pc_ega_3X0_r: offset = %02x\n", offset );
1142   }
1143
11441164   switch ( offset )
11451165   {
11461166   /* CRT Controller - address register */
r15502r15503
11501170
11511171   /* CRT Controller - data register */
11521172   case 1: case 3: case 5: case 7:
1153      data = crtc_ega_register_r( m_crtc_ega, offset );
1173      data = m_crtc_ega->register_r( space, offset );
11541174      break;
11551175
11561176   /* Input Status Register 1 */
11571177   case 10:
1158      data = m_vblank | m_display_enable;
1178      data = m_vblank | ( m_hsync | m_vsync ); //  m_display_enable;
11591179
11601180      if ( m_display_enable )
11611181      {
r15502r15503
11741194   return data;
11751195}
11761196
1177void isa8_ega_device::pc_ega8_3X0_w(UINT8 offset, UINT8 data)
1197WRITE8_MEMBER( isa8_ega_device::pc_ega8_3X0_w )
11781198{
11791199   if ( VERBOSE_EGA )
11801200   {
1181      logerror("pc_ega_3X0_w: offset = %02x, data = %02x\n", offset, data );
1201//      logerror("pc_ega_3X0_w: offset = %02x, data = %02x\n", offset, data );
11821202   }
11831203
11841204   switch ( offset )
11851205   {
11861206   /* CRT Controller - address register */
11871207   case 0: case 2: case 4: case 6:
1188      crtc_ega_address_w( m_crtc_ega, offset, data );
1208      m_crtc_ega->address_w( space, offset, data );
11891209      break;
11901210
11911211   /* CRT Controller - data register */
11921212   case 1: case 3: case 5: case 7:
1193      crtc_ega_register_w( m_crtc_ega, offset, data );
1213      m_crtc_ega->register_w( space, offset, data );
11941214      break;
11951215
11961216   /* Set Light Pen Flip Flop */
r15502r15503
12121232
12131233READ8_MEMBER(isa8_ega_device::pc_ega8_3b0_r )
12141234{
1215   return ( m_misc_output & 0x01 ) ? 0xFF : pc_ega8_3X0_r(offset);
1235   return ( m_misc_output & 0x01 ) ? 0xFF : pc_ega8_3X0_r(space, offset);
12161236}
12171237
12181238
12191239READ8_MEMBER(isa8_ega_device::pc_ega8_3d0_r )
12201240{
1221   return ( m_misc_output & 0x01 ) ? pc_ega8_3X0_r(offset) : 0xFF;
1241   return ( m_misc_output & 0x01 ) ? pc_ega8_3X0_r(space, offset) : 0xFF;
12221242}
12231243
12241244
r15502r15503
12261246{
12271247   if ( ! ( m_misc_output & 0x01 ) )
12281248   {
1229      pc_ega8_3X0_w(offset, data );
1249      pc_ega8_3X0_w( space, offset, data );
12301250   }
12311251}
12321252
r15502r15503
12351255{
12361256   if ( m_misc_output & 0x01 )
12371257   {
1238      pc_ega8_3X0_w(offset, data );
1258      pc_ega8_3X0_w( space, offset, data );
12391259   }
12401260}
12411261
r15502r15503
12461266
12471267   if ( VERBOSE_EGA )
12481268   {
1249      logerror("pc_ega_3c0_r: offset = %02x\n", offset );
1269//      logerror("pc_ega_3c0_r: offset = %02x\n", offset );
12501270   }
12511271
12521272   switch ( offset )
r15502r15503
13051325
13061326   if ( VERBOSE_EGA )
13071327   {
1308      logerror("pc_ega_3c0_w: offset = %02x, data = %02x\n", offset, data );
1328//      logerror("pc_ega_3c0_w: offset = %02x, data = %02x\n", offset, data );
13091329   }
13101330
13111331   switch ( offset )
src/mess/video/isa_ega.h
r15502r15503
3535      DECLARE_WRITE8_MEMBER(pc_ega8_3c0_w);
3636      DECLARE_READ8_MEMBER(pc_ega8_3d0_r);
3737      DECLARE_WRITE8_MEMBER(pc_ega8_3d0_w);
38      DECLARE_WRITE_LINE_MEMBER(de_changed);
39      DECLARE_WRITE_LINE_MEMBER(hsync_changed);
40      DECLARE_WRITE_LINE_MEMBER(vsync_changed);
41      DECLARE_WRITE_LINE_MEMBER(vblank_changed);
42
3843protected:
3944        // device-level overrides
4045        virtual void device_start();
4146        virtual void device_reset();
4247
48      UINT8 alu_op( UINT8 data, UINT8 latch_data );
49
4350public:
44      device_t *m_crtc_ega;
51      crtc_ega_device *m_crtc_ega;
4552
4653      void install_banks();
4754      void change_mode();
48      void pc_ega8_3X0_w(UINT8 offset, UINT8 data);
49      UINT8 pc_ega8_3X0_r(UINT8 offset);
55      DECLARE_WRITE8_MEMBER(pc_ega8_3X0_w);
56      DECLARE_READ8_MEMBER(pc_ega8_3X0_r);
5057
5158      crtc_ega_update_row_func   m_update_row;
5259
r15502r15503
8592      } m_graphics_controller;
8693
8794      UINT8   m_frame_cnt;
95      UINT8   m_hsync;
8896      UINT8   m_vsync;
8997      UINT8   m_vblank;
9098      UINT8   m_display_enable;
src/mess/video/crtc_ega.c
r15502r15503
1313#define LOG      (1)
1414
1515
16/* device types */
17enum
18{
19   TYPE_CRTC_EGA=0,
20   TYPE_CRTC_VGA,
16const device_type CRTC_EGA = &device_creator<crtc_ega_device>;
2117
22   NUM_TYPES
23};
2418
25
26/* tags for state saving */
27static const char * const device_tags[NUM_TYPES] = { "crtc_ega", "crtc_vga" };
28
29
30typedef struct _crtc_ega_t crtc_ega_t;
31struct _crtc_ega_t
19void crtc_ega_device::device_config_complete()
3220{
33   int device_type;
34   const crtc_ega_interface *intf;
35   screen_device *screen;
21   const crtc_ega_interface *intf = reinterpret_cast<const crtc_ega_interface *>(static_config());
3622
37   /* ega/vga register file */
38   UINT8   horiz_char_total;   /* 0x00 */
39   UINT8   horiz_disp;         /* 0x01 */
40   UINT8   horiz_blank_start;   /* 0x02 */
41   UINT8   horiz_blank_end;   /* 0x03/0x05 */
42   UINT8   ena_vert_access;   /* 0x03 */
43   UINT8   de_skew;         /* 0x03 */
44   UINT8   horiz_retr_start;   /* 0x04 */
45   UINT8   horiz_retr_end;      /* 0x05 */
46   UINT8   horiz_retr_skew;   /* 0x05 */
47   UINT16   vert_total;         /* 0x06/0x07 */
48   UINT8   preset_row_scan;   /* 0x08 */
49   UINT8   byte_panning;      /* 0x08 */
50   UINT8   max_ras_addr;      /* 0x09 */
51   UINT8   scan_doubling;      /* 0x09 */
52   UINT8   cursor_start_ras;   /* 0x0a */
53   UINT8   cursor_disable;      /* 0x0a */
54   UINT8   cursor_end_ras;      /* 0x0b */
55   UINT8   cursor_skew;      /* 0x0b */
56   UINT16   disp_start_addr;   /* 0x0c/0x0d */
57   UINT16   cursor_addr;      /* 0x0e/0x0f */
58   UINT16   light_pen_addr;      /* 0x10/0x11 */
59   UINT16   vert_retr_start;   /* 0x10/0x07 */
60   UINT8   vert_retr_end;      /* 0x11 */
61   UINT8   protect;         /* 0x11 */
62   UINT8   bandwidth;         /* 0x11 */
63   UINT16   vert_disp_end;      /* 0x12/0x07 */
64   UINT8   offset;            /* 0x13 */
65   UINT8   underline_loc;      /* 0x14 */
66   UINT16   vert_blank_start;   /* 0x15/0x07/0x09 */
67   UINT8   vert_blank_end;      /* 0x16 */
68   UINT8   mode_control;      /* 0x17 */
69   UINT16   line_compare;      /* 0x18/0x07/0x09 */
23   if ( intf != NULL )
24   {
25      *static_cast<crtc_ega_interface *>(this) = *intf;
26   }
27   else
28   {
29      m_screen_tag = NULL;
30      m_hpixels_per_column = 0;
31      m_begin_update = NULL;
32      m_update_row = NULL;
33      m_end_update = NULL;
34      memset(&m_out_de_func, 0, sizeof(m_out_de_func));
35      memset(&m_out_hsync_func, 0, sizeof(m_out_hsync_func));
36      memset(&m_out_vsync_func, 0, sizeof(m_out_vsync_func));
37      memset(&m_out_vblank_func, 0, sizeof(m_out_vblank_func));
38   }
39}
7040
71   /* other internal state */
72   UINT64   clock;
73   UINT8   register_address_latch;
74   UINT8   hpixels_per_column;
75   UINT8   cursor_state;   /* 0 = off, 1 = on */
76   UINT8   cursor_blink_count;
7741
78   /* timers */
79   emu_timer *de_changed_timer;
80   emu_timer *hsync_on_timer;
81   emu_timer *hsync_off_timer;
82   emu_timer *vsync_on_timer;
83   emu_timer *vsync_off_timer;
84   emu_timer *vblank_on_timer;
85   emu_timer *vblank_off_timer;
86   emu_timer *light_pen_latch_timer;
87
88   /* computed values - do NOT state save these! */
89   UINT16   horiz_pix_total;
90   UINT16   vert_pix_total;
91   UINT16   max_visible_x;
92   UINT16   max_visible_y;
93   UINT16   hsync_on_pos;
94   UINT16   hsync_off_pos;
95   UINT16   vsync_on_pos;
96   UINT16   vsync_off_pos;
97   UINT16  current_disp_addr;   /* the display address currently drawn */
98   UINT8   light_pen_latched;
99   int      has_valid_parameters;
100};
101
102//static DEVICE_GET_INFO( crtc_vga );
103
104static void recompute_parameters(crtc_ega_t *crtc_ega, int postload);
105static void update_de_changed_timer(crtc_ega_t *crtc_ega);
106static void update_hsync_changed_timers(crtc_ega_t *crtc_ega);
107static void update_vsync_changed_timers(crtc_ega_t *crtc_ega);
108static void update_vblank_changed_timers(crtc_ega_t *crtc_ega);
109
110
111/* makes sure that the passed in device is the right type */
112INLINE crtc_ega_t *get_safe_token(device_t *device)
42crtc_ega_device::crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
43   : device_t(mconfig, CRTC_EGA, "crtc_EGA", tag, owner, clock)
11344{
114   assert(device != NULL);
115   assert((device->type() == CRTC_EGA) ||
116         /*(device->type() == DEVICE_GET_INFO_NAME(crtc_vga))*/0 );
117
118   return (crtc_ega_t *)downcast<legacy_device_base *>(device)->token();
11945}
12046
12147
122static void crtc_ega_state_save_postload(crtc_ega_t *state)
48void crtc_ega_device::device_post_load()
12349{
124   recompute_parameters(state, TRUE);
50   recompute_parameters(true);
12551}
12652
12753
128WRITE8_DEVICE_HANDLER( crtc_ega_address_w )
54WRITE8_MEMBER( crtc_ega_device::address_w )
12955{
130   crtc_ega_t *crtc_ega = get_safe_token(device);
131
132   crtc_ega->register_address_latch = data & 0x1f;
56   m_register_address_latch = data & 0x1f;
13357}
13458
13559
136READ8_DEVICE_HANDLER( crtc_ega_register_r )
60READ8_MEMBER( crtc_ega_device::register_r )
13761{
138   crtc_ega_t *crtc_ega = get_safe_token(device);
13962   UINT8 ret = 0;
14063
141   switch (crtc_ega->register_address_latch)
64   switch (m_register_address_latch)
14265   {
143      case 0x0c:  ret = (crtc_ega->disp_start_addr >> 8) & 0xff; break;
144      case 0x0d:  ret = (crtc_ega->disp_start_addr >> 0) & 0xff; break;
145      case 0x0e:  ret = (crtc_ega->cursor_addr    >> 8) & 0xff; break;
146      case 0x0f:  ret = (crtc_ega->cursor_addr    >> 0) & 0xff; break;
147      case 0x10:  ret = (crtc_ega->light_pen_addr >> 8) & 0xff; crtc_ega->light_pen_latched = FALSE; break;
148      case 0x11:  ret = (crtc_ega->light_pen_addr >> 0) & 0xff; crtc_ega->light_pen_latched = FALSE; break;
66      case 0x0c:  ret = (m_disp_start_addr >> 8) & 0xff; break;
67      case 0x0d:  ret = (m_disp_start_addr >> 0) & 0xff; break;
68      case 0x0e:  ret = (m_cursor_addr    >> 8) & 0xff; break;
69      case 0x0f:  ret = (m_cursor_addr    >> 0) & 0xff; break;
70      case 0x10:  ret = (m_light_pen_addr >> 8) & 0xff; m_light_pen_latched = FALSE; break;
71      case 0x11:  ret = (m_light_pen_addr >> 0) & 0xff; m_light_pen_latched = FALSE; break;
14972
15073      /* all other registers are write only and return 0 */
15174      default: break;
r15502r15503
15578}
15679
15780
158WRITE8_DEVICE_HANDLER( crtc_ega_register_w )
81WRITE8_MEMBER( crtc_ega_device::register_w )
15982{
160   crtc_ega_t *crtc_ega = get_safe_token(device);
83   if (LOG)  logerror("CRTC_EGA PC %04x: reg 0x%02x = 0x%02x\n", cpu_get_pc(machine().firstcpu), m_register_address_latch, data);
16184
162   if (LOG)  logerror("CRTC_EGA PC %04x: reg 0x%02x = 0x%02x\n", cpu_get_pc(device->machine().firstcpu), crtc_ega->register_address_latch, data);
163
164   switch (crtc_ega->register_address_latch)
85   switch (m_register_address_latch)
16586   {
166      case 0x00:  crtc_ega->horiz_char_total  =   data & 0xff; break;
167      case 0x01:  crtc_ega->horiz_disp        =   data & 0xff; break;
168      case 0x02:  crtc_ega->horiz_blank_start =   data & 0xff; break;
169      case 0x03:  crtc_ega->horiz_blank_end   =  ((data & 0x1f) << 0) | (crtc_ega->horiz_blank_end & 0x20);
170               crtc_ega->de_skew           =  ((data & 0x60) >> 5);
171               crtc_ega->ena_vert_access   =  data & 0x80;
87      case 0x00:  m_horiz_char_total  =   data & 0xff; break;
88      case 0x01:  m_horiz_disp        =   data & 0xff; break;
89      case 0x02:  m_horiz_blank_start =   data & 0xff; break;
90      case 0x03:  m_horiz_blank_end   =  ((data & 0x1f) << 0) | (m_horiz_blank_end & 0x20);
91               m_de_skew           =  ((data & 0x60) >> 5);
92               m_ena_vert_access   =  data & 0x80;
17293               break;
173      case 0x04:  crtc_ega->horiz_retr_start  =   data & 0xff; break;
174      case 0x05:  crtc_ega->horiz_retr_end    =   data & 0x1f;
175               crtc_ega->horiz_retr_skew   = ((data & 0x60) >> 5);
176               crtc_ega->horiz_blank_end   = ((data & 0x80) >> 2) | (crtc_ega->horiz_blank_end & 0x1f);
94      case 0x04:  m_horiz_retr_start  =   data & 0xff; break;
95      case 0x05:  m_horiz_retr_end    =   data & 0x1f;
96               m_horiz_retr_skew   = ((data & 0x60) >> 5);
97               m_horiz_blank_end   = ((data & 0x80) >> 2) | (m_horiz_blank_end & 0x1f);
17798               break;
178      case 0x06:  crtc_ega->vert_total        = ((data & 0xff) << 0) | (crtc_ega->vert_total & 0x0300); break;
179      case 0x07:  crtc_ega->vert_total        = ((data & 0x01) << 8) | (crtc_ega->vert_total & 0x02ff);
180               crtc_ega->vert_disp_end     = ((data & 0x02) << 7) | (crtc_ega->vert_disp_end & 0x02ff);
181               crtc_ega->vert_retr_start   = ((data & 0x04) << 6) | (crtc_ega->vert_retr_start & 0x02ff);
182               crtc_ega->vert_blank_start  = ((data & 0x08) << 5) | (crtc_ega->vert_blank_start & 0x02ff);
183               crtc_ega->line_compare      = ((data & 0x10) << 4) | (crtc_ega->line_compare & 0x02ff);
184               crtc_ega->vert_total        = ((data & 0x20) << 4) | (crtc_ega->vert_total & 0x01ff);
185               crtc_ega->vert_disp_end     = ((data & 0x40) << 3) | (crtc_ega->vert_disp_end & 0x1ff);
186               crtc_ega->vert_retr_start   = ((data & 0x80) << 2) | (crtc_ega->vert_retr_start & 0x01ff);
99      case 0x06:  m_vert_total        = ((data & 0xff) << 0) | (m_vert_total & 0x0300); break;
100      case 0x07:  m_vert_total        = ((data & 0x01) << 8) | (m_vert_total & 0x02ff);
101               m_vert_disp_end     = ((data & 0x02) << 7) | (m_vert_disp_end & 0x02ff);
102               m_vert_retr_start   = ((data & 0x04) << 6) | (m_vert_retr_start & 0x02ff);
103               m_vert_blank_start  = ((data & 0x08) << 5) | (m_vert_blank_start & 0x02ff);
104               m_line_compare      = ((data & 0x10) << 4) | (m_line_compare & 0x02ff);
105               m_vert_total        = ((data & 0x20) << 4) | (m_vert_total & 0x01ff);
106               m_vert_disp_end     = ((data & 0x40) << 3) | (m_vert_disp_end & 0x1ff);
107               m_vert_retr_start   = ((data & 0x80) << 2) | (m_vert_retr_start & 0x01ff);
187108               break;
188      case 0x08:  crtc_ega->preset_row_scan   =   data & 0x1f;
189               crtc_ega->byte_panning      = ((data & 0x60) >> 5);
109      case 0x08:  m_preset_row_scan   =   data & 0x1f;
110               m_byte_panning      = ((data & 0x60) >> 5);
190111               break;
191      case 0x09:  crtc_ega->max_ras_addr      =   data & 0x1f;
192               crtc_ega->vert_blank_start  = ((data & 0x20) << 4) | (crtc_ega->vert_blank_start & 0x01ff);
193               crtc_ega->line_compare      = ((data & 0x40) << 3) | (crtc_ega->line_compare & 0x01ff);
194               crtc_ega->scan_doubling     =   data & 0x80;
112      case 0x09:  m_max_ras_addr      =   data & 0x1f;
113               m_vert_blank_start  = ((data & 0x20) << 4) | (m_vert_blank_start & 0x01ff);
114               m_line_compare      = ((data & 0x40) << 3) | (m_line_compare & 0x01ff);
115               m_scan_doubling     =   data & 0x80;
195116               break;
196      case 0x0a:  crtc_ega->cursor_start_ras  =   data & 0x1f;
197               crtc_ega->cursor_disable    =   data & 0x20;
117      case 0x0a:  m_cursor_start_ras  =   data & 0x1f;
118               m_cursor_disable    =   data & 0x20;
198119               break;
199      case 0x0b:  crtc_ega->cursor_end_ras    =   data & 0x1f;
200               crtc_ega->cursor_skew       = ((data & 0x60) >> 5);
120      case 0x0b:  m_cursor_end_ras    =   data & 0x1f;
121               m_cursor_skew       = ((data & 0x60) >> 5);
201122               break;
202      case 0x0c:  crtc_ega->disp_start_addr   = ((data & 0xff) << 8) | (crtc_ega->disp_start_addr & 0x00ff); break;
203      case 0x0d:  crtc_ega->disp_start_addr   = ((data & 0xff) << 0) | (crtc_ega->disp_start_addr & 0xff00); break;
204      case 0x0e:  crtc_ega->cursor_addr       = ((data & 0xff) << 8) | (crtc_ega->cursor_addr & 0x00ff); break;
205      case 0x0f:  crtc_ega->cursor_addr       = ((data & 0xff) << 0) | (crtc_ega->cursor_addr & 0xff00); break;
206      case 0x10:   crtc_ega->vert_retr_start   = ((data & 0xff) << 0) | (crtc_ega->vert_retr_start & 0x03ff); break;
207      case 0x11:   crtc_ega->vert_retr_end     =   data & 0x0f;
208               crtc_ega->bandwidth         =   data & 0x40;
209               crtc_ega->protect           =   data & 0x80;
123      case 0x0c:  m_disp_start_addr   = ((data & 0xff) << 8) | (m_disp_start_addr & 0x00ff); break;
124      case 0x0d:  m_disp_start_addr   = ((data & 0xff) << 0) | (m_disp_start_addr & 0xff00); break;
125      case 0x0e:  m_cursor_addr       = ((data & 0xff) << 8) | (m_cursor_addr & 0x00ff); break;
126      case 0x0f:  m_cursor_addr       = ((data & 0xff) << 0) | (m_cursor_addr & 0xff00); break;
127      case 0x10:   m_vert_retr_start   = ((data & 0xff) << 0) | (m_vert_retr_start & 0x0300); break;
128      case 0x11:   m_vert_retr_end     =   data & 0x0f;
129               m_bandwidth         =   data & 0x40;
130               m_protect           =   data & 0x80;
210131               break;
211      case 0x12:   crtc_ega->vert_disp_end     = ((data & 0xff) << 0) | (crtc_ega->vert_disp_end & 0x0300); break;
212      case 0x13:   crtc_ega->offset            =  data & 0xff; break;
213      case 0x14:   crtc_ega->underline_loc     =  data & 0x7f; break;
214      case 0x15:   crtc_ega->vert_blank_start  = ((data & 0xff) << 0) | (crtc_ega->vert_blank_start & 0x0300); break;
215      case 0x16:   crtc_ega->vert_blank_end    =   data & 0x7f; break;
216      case 0x17:   crtc_ega->mode_control      =   data & 0xff; break;
217      case 0x18:   crtc_ega->line_compare      = ((data & 0xff) << 0) | (crtc_ega->line_compare & 0x0300); break;
132      case 0x12:   m_vert_disp_end     = ((data & 0xff) << 0) | (m_vert_disp_end & 0x0300); break;
133      case 0x13:   m_offset            =  data & 0xff; break;
134      case 0x14:   m_underline_loc     =  data & 0x7f; break;
135      case 0x15:   m_vert_blank_start  = ((data & 0xff) << 0) | (m_vert_blank_start & 0x0300); break;
136      case 0x16:   m_vert_blank_end    =   data & 0x7f; break;
137      case 0x17:   m_mode_control      =   data & 0xff; break;
138      case 0x18:   m_line_compare      = ((data & 0xff) << 0) | (m_line_compare & 0x0300); break;
218139      default:   break;
219140   }
220141
221//  /* display message if the Mode Control register is not zero */
222//  if ((crtc_ega->register_address_latch == 0x08) && (crtc_ega->mode_control != 0))
223//      popmessage("Mode Control %02X is not supported!!!", crtc_ega->mode_control);
224
225   recompute_parameters(crtc_ega, FALSE);
142   recompute_parameters(false);
226143}
227144
228145
229static void recompute_parameters(crtc_ega_t *crtc_ega, int postload)
146void crtc_ega_device::recompute_parameters(bool postload)
230147{
231   if (crtc_ega->intf != NULL)
232   {
233      UINT16 hsync_on_pos, hsync_off_pos, vsync_on_pos, vsync_off_pos;
148   UINT16 hsync_on_pos, hsync_off_pos, vsync_on_pos, vsync_off_pos;
234149
235      /* compute the screen sizes */
236      UINT16 horiz_pix_total = (crtc_ega->horiz_char_total + 5) * crtc_ega->hpixels_per_column;
237      UINT16 vert_pix_total = crtc_ega->vert_total + 1;
150   /* compute the screen sizes */
151   UINT16 horiz_pix_total = (m_horiz_char_total + 2) * m_hpixels_per_column;
152   UINT16 vert_pix_total = m_vert_total + 1;
238153
239      /* determine the visible area, avoid division by 0 */
240      UINT16 max_visible_x = ( crtc_ega->horiz_disp + 1 ) * crtc_ega->hpixels_per_column - 1;
241      UINT16 max_visible_y = crtc_ega->vert_disp_end;
154   /* determine the visible area, avoid division by 0 */
155   UINT16 max_visible_x = ( m_horiz_disp + 1 ) * m_hpixels_per_column - 1;
156   UINT16 max_visible_y = m_vert_disp_end;
242157
243      /* determine the syncing positions */
244      int horiz_sync_char_width = ( crtc_ega->horiz_retr_end + 1 ) - ( crtc_ega->horiz_retr_start & 0x1f );
245      int vert_sync_pix_width = crtc_ega->vert_retr_end - ( crtc_ega->vert_retr_start & 0x0f );
158   /* determine the syncing positions */
159   int horiz_sync_char_width = ( m_horiz_retr_end + 1 ) - ( m_horiz_retr_start & 0x1f );
160   int vert_sync_pix_width = m_vert_retr_end - ( m_vert_retr_start & 0x0f );
246161
247      if (horiz_sync_char_width <= 0)
248         horiz_sync_char_width += 0x10;
162   if (horiz_sync_char_width <= 0)
163      horiz_sync_char_width += 0x10;
249164
250      if (vert_sync_pix_width <= 0)
251         vert_sync_pix_width += 0x10;
165   if (vert_sync_pix_width <= 0)
166      vert_sync_pix_width += 0x10;
252167
253      hsync_on_pos = crtc_ega->horiz_retr_start * crtc_ega->hpixels_per_column;
254      hsync_off_pos = hsync_on_pos + (horiz_sync_char_width * crtc_ega->hpixels_per_column);
255      vsync_on_pos = crtc_ega->vert_retr_start;      /* + 1 ?? */
256      vsync_off_pos = vsync_on_pos + vert_sync_pix_width;
168   hsync_on_pos = m_horiz_retr_start * m_hpixels_per_column;
169   hsync_off_pos = hsync_on_pos + (horiz_sync_char_width * m_hpixels_per_column);
170   vsync_on_pos = m_vert_retr_start;      /* + 1 ?? */
171   vsync_off_pos = vsync_on_pos + vert_sync_pix_width;
257172
258      if (hsync_off_pos > horiz_pix_total)
259         hsync_off_pos = horiz_pix_total;
173   if (hsync_off_pos > horiz_pix_total)
174      hsync_off_pos = horiz_pix_total;
260175
261      if (vsync_off_pos > vert_pix_total)
262         vsync_off_pos = vert_pix_total;
176   if (vsync_off_pos > vert_pix_total)
177      vsync_off_pos = vert_pix_total;
263178
264      if ( vsync_on_pos >= vsync_off_pos )
265      {
266         vsync_on_pos = vsync_off_pos - 2;
267      }
179   if ( vsync_on_pos >= vsync_off_pos )
180   {
181      vsync_on_pos = vsync_off_pos - 2;
182   }
268183
269      /* update only if screen parameters changed, unless we are coming here after loading the saved state */
270      if (postload ||
271          (horiz_pix_total != crtc_ega->horiz_pix_total) || (vert_pix_total != crtc_ega->vert_pix_total) ||
272         (max_visible_x != crtc_ega->max_visible_x) || (max_visible_y != crtc_ega->max_visible_y) ||
273         (hsync_on_pos != crtc_ega->hsync_on_pos) || (vsync_on_pos != crtc_ega->vsync_on_pos) ||
274         (hsync_off_pos != crtc_ega->hsync_off_pos) || (vsync_off_pos != crtc_ega->vsync_off_pos))
184   /* update only if screen parameters changed, unless we are coming here after loading the saved state */
185   if (postload ||
186       (horiz_pix_total != m_horiz_pix_total) || (vert_pix_total != m_vert_pix_total) ||
187      (max_visible_x != m_max_visible_x) || (max_visible_y != m_max_visible_y) ||
188      (hsync_on_pos != m_hsync_on_pos) || (vsync_on_pos != m_vsync_on_pos) ||
189      (hsync_off_pos != m_hsync_off_pos) || (vsync_off_pos != m_vsync_off_pos))
190   {
191      /* update the screen if we have valid data */
192      if ((horiz_pix_total > 0) && (max_visible_x < horiz_pix_total) &&
193         (vert_pix_total > 0) && (max_visible_y < vert_pix_total) &&
194         (hsync_on_pos <= horiz_pix_total) && (vsync_on_pos <= vert_pix_total) &&
195         (hsync_on_pos != hsync_off_pos))
275196      {
276         /* update the screen if we have valid data */
277         if ((horiz_pix_total > 0) && (max_visible_x < horiz_pix_total) &&
278            (vert_pix_total > 0) && (max_visible_y < vert_pix_total) &&
279            (hsync_on_pos <= horiz_pix_total) && (vsync_on_pos <= vert_pix_total) &&
280            (hsync_on_pos != hsync_off_pos))
281         {
282            attoseconds_t refresh = HZ_TO_ATTOSECONDS(crtc_ega->clock) * (crtc_ega->horiz_char_total + 1) * vert_pix_total;
197         attoseconds_t refresh = HZ_TO_ATTOSECONDS(m_clock) * (m_horiz_char_total + 2) * vert_pix_total;
283198
284            rectangle visarea(0, max_visible_x, 0, max_visible_y);
199         rectangle visarea(0, max_visible_x, 0, max_visible_y);
285200
286            if (LOG) logerror("CRTC_EGA config screen: HTOTAL: 0x%x  VTOTAL: 0x%x  MAX_X: 0x%x  MAX_Y: 0x%x  HSYNC: 0x%x-0x%x  VSYNC: 0x%x-0x%x  Freq: %ffps\n",
287                          horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
201         if (LOG) logerror("CRTC_EGA config screen: HTOTAL: 0x%x  VTOTAL: 0x%x  MAX_X: 0x%x  MAX_Y: 0x%x  HSYNC: 0x%x-0x%x  VSYNC: 0x%x-0x%x  Freq: %ffps\n",
202                       horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
288203
289            crtc_ega->screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
204         if ( m_screen != NULL )
205            m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
290206
291            crtc_ega->has_valid_parameters = TRUE;
292         }
293         else
294         {
295            crtc_ega->has_valid_parameters = FALSE;
296            if (LOG) logerror("CRTC_EGA bad config screen: HTOTAL: 0x%x  VTOTAL: 0x%x  MAX_X: 0x%x  MAX_Y: 0x%x  HSYNC: 0x%x-0x%x  VSYNC: 0x%x-0x%x\n",
297                               horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1);
207         m_has_valid_parameters = true;
208      }
209      else
210      {
211         m_has_valid_parameters = false;
212         if (LOG) logerror("CRTC_EGA bad config screen: HTOTAL: 0x%x  VTOTAL: 0x%x  MAX_X: 0x%x  MAX_Y: 0x%x  HSYNC: 0x%x-0x%x  VSYNC: 0x%x-0x%x\n",
213                            horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1);
298214
299         }
300
301         crtc_ega->horiz_pix_total = horiz_pix_total;
302         crtc_ega->vert_pix_total = vert_pix_total;
303         crtc_ega->max_visible_x = max_visible_x;
304         crtc_ega->max_visible_y = max_visible_y;
305         crtc_ega->hsync_on_pos = hsync_on_pos;
306         crtc_ega->hsync_off_pos = hsync_off_pos;
307         crtc_ega->vsync_on_pos = vsync_on_pos;
308         crtc_ega->vsync_off_pos = vsync_off_pos;
309
310         update_de_changed_timer(crtc_ega);
311         update_hsync_changed_timers(crtc_ega);
312         update_vsync_changed_timers(crtc_ega);
313         update_vblank_changed_timers(crtc_ega);
314215      }
216
217      m_horiz_pix_total = horiz_pix_total;
218      m_vert_pix_total = vert_pix_total;
219      m_max_visible_x = max_visible_x;
220      m_max_visible_y = max_visible_y;
221      m_hsync_on_pos = hsync_on_pos;
222      m_hsync_off_pos = hsync_off_pos;
223      m_vsync_on_pos = vsync_on_pos;
224      m_vsync_off_pos = vsync_off_pos;
315225   }
316226}
317227
318228
319INLINE int is_display_enabled(crtc_ega_t *crtc_ega)
229void crtc_ega_device::update_counters()
320230{
321   return !crtc_ega->screen->vblank() && !crtc_ega->screen->hblank();
322}
231   m_character_counter = m_line_timer->elapsed().as_ticks( m_clock );
323232
324
325static void update_de_changed_timer(crtc_ega_t *crtc_ega)
326{
327   if (crtc_ega->has_valid_parameters && (crtc_ega->de_changed_timer != NULL))
233   if ( m_hsync_off_timer->enabled() )
328234   {
329      INT16 next_y;
330      UINT16 next_x;
331      attotime duration;
332
333      /* we are in a display region, get the location of the next blanking start */
334      if (is_display_enabled(crtc_ega))
335      {
336         /* normally, it's at end the current raster line */
337         next_y = crtc_ega->screen->vpos();
338         next_x = crtc_ega->max_visible_x + 1;
339
340         /* but if visible width = horiz_pix_total, then we need
341               to go to the beginning of VBLANK */
342         if (next_x == crtc_ega->horiz_pix_total)
343         {
344            next_y = crtc_ega->max_visible_y + 1;
345            next_x = 0;
346
347            /* abnormal case, no vertical blanking, either */
348            if (next_y == crtc_ega->vert_pix_total)
349               next_y = -1;
350         }
351      }
352
353      /* we are in a blanking region, get the location of the next display start */
354      else
355      {
356         next_x = 0;
357         next_y = (crtc_ega->screen->vpos() + 1) % crtc_ega->vert_pix_total;
358
359         /* if we would now fall in the vertical blanking, we need
360               to go to the top of the screen */
361         if (next_y > crtc_ega->max_visible_y)
362            next_y = 0;
363      }
364
365      if (next_y != -1)
366         duration = crtc_ega->screen->time_until_pos(next_y, next_x);
367      else
368         duration = attotime::never;
369
370      crtc_ega->de_changed_timer->adjust(duration);
235      m_hsync_width_counter = m_hsync_off_timer->elapsed().as_ticks( m_clock );
371236   }
372237}
373238
374239
375static void update_hsync_changed_timers(crtc_ega_t *crtc_ega)
240void crtc_ega_device::set_de(int state)
376241{
377   if (crtc_ega->has_valid_parameters && (crtc_ega->hsync_on_timer != NULL))
242   if ( m_de != state )
378243   {
379      UINT16 next_y;
244      m_de = state;
380245
381      /* we are before the HSYNC position, we trigger on the current line */
382      if (crtc_ega->screen->hpos() < crtc_ega->hsync_on_pos)
383         next_y = crtc_ega->screen->vpos();
384
385      /* trigger on the next line */
386      else
387         next_y = (crtc_ega->screen->vpos() + 1) % crtc_ega->vert_pix_total;
388
389      /* if the next line is not in the visible region, go to the beginning of the screen */
390      if (next_y > crtc_ega->max_visible_y)
391         next_y = 0;
392
393      crtc_ega->hsync_on_timer->adjust(crtc_ega->screen->time_until_pos(next_y, crtc_ega->hsync_on_pos) );
394      crtc_ega->hsync_off_timer->adjust(crtc_ega->screen->time_until_pos(next_y, crtc_ega->hsync_off_pos));
246      if ( !m_res_out_de_func.isnull() )
247         m_res_out_de_func( m_de );
395248   }
396249}
397250
398251
399static void update_vsync_changed_timers(crtc_ega_t *crtc_ega)
252void crtc_ega_device::set_hsync(int state)
400253{
401   if (crtc_ega->has_valid_parameters && (crtc_ega->vsync_on_timer != NULL))
254   if ( m_hsync != state )
402255   {
403      crtc_ega->vsync_on_timer->adjust(crtc_ega->screen->time_until_pos(crtc_ega->vsync_on_pos,  0));
404      crtc_ega->vsync_off_timer->adjust(crtc_ega->screen->time_until_pos(crtc_ega->vsync_off_pos, 0));
256      m_hsync = state;
257
258      if ( !m_res_out_hsync_func.isnull() )
259         m_res_out_hsync_func( m_hsync );
405260   }
406261}
407262
408263
409static void update_vblank_changed_timers(crtc_ega_t *crtc_ega)
264void crtc_ega_device::set_vsync(int state)
410265{
411   if (crtc_ega->has_valid_parameters && (crtc_ega->vblank_on_timer != NULL))
266   if ( m_vsync != state )
412267   {
413      crtc_ega->vblank_on_timer->adjust(crtc_ega->screen->time_until_pos(crtc_ega->vert_disp_end,  crtc_ega->hsync_off_pos));
414      crtc_ega->vblank_off_timer->adjust(crtc_ega->screen->time_until_pos(0, crtc_ega->hsync_on_pos));
268      m_vsync = state;
269
270      if ( !m_res_out_vsync_func.isnull() )
271         m_res_out_vsync_func( m_vsync );
415272   }
416273}
417274
418275
419static TIMER_CALLBACK( de_changed_timer_cb )
276void crtc_ega_device::set_vblank(int state)
420277{
421   device_t *device = (device_t *)ptr;
422   crtc_ega_t *crtc_ega = get_safe_token(device);
278   if ( m_vblank != state )
279   {
280      m_vblank = state;
423281
424   /* call the callback function -- we know it exists */
425   crtc_ega->intf->on_de_changed(device, is_display_enabled(crtc_ega));
426
427   update_de_changed_timer(crtc_ega);
282      if ( !m_res_out_vblank_func.isnull() )
283         m_res_out_vblank_func( m_vblank );
284   }
428285}
429286
430287
431static TIMER_CALLBACK( vsync_on_timer_cb )
288void crtc_ega_device::set_cur(int state)
432289{
433   device_t *device = (device_t *)ptr;
434   crtc_ega_t *crtc_ega = get_safe_token(device);
290   if ( m_cur != state )
291   {
292      m_cur = state;
435293
436   /* call the callback function -- we know it exists */
437   crtc_ega->intf->on_vsync_changed(device, TRUE);
294//      if ( !m_res_out_cur_func.isnull() )
295//         m_res_out_cur_func( m_cur );
296   }
438297}
439298
440299
441static TIMER_CALLBACK( vsync_off_timer_cb )
300void crtc_ega_device::handle_line_timer()
442301{
443   device_t *device = (device_t *)ptr;
444   crtc_ega_t *crtc_ega = get_safe_token(device);
302   int new_vsync = m_vsync;
445303
446   /* call the callback function -- we know it exists */
447   crtc_ega->intf->on_vsync_changed(device, FALSE);
304   m_character_counter = 0;
305   m_cursor_x = -1;
448306
449   update_vsync_changed_timers(crtc_ega);
450}
307   /* Check if VSYNC is active */
308   if ( m_vsync_ff )
309   {
310      m_vsync_width_counter = ( m_vsync_width_counter + 1 ) & 0x0F;
451311
312      /* Check if we've reached end of VSYNC */
313      if ( m_vsync_width_counter == m_vert_retr_end )
314      {
315         m_vsync_ff = 0;
452316
453static TIMER_CALLBACK( hsync_on_timer_cb )
454{
455   device_t *device = (device_t *)ptr;
456   crtc_ega_t *crtc_ega = get_safe_token(device);
317         new_vsync = FALSE;
318      }
319   }
457320
458   /* call the callback function -- we know it exists */
459   crtc_ega->intf->on_hsync_changed(device, TRUE);
460}
321   if ( m_raster_counter == m_max_ras_addr )
322   {
323      m_raster_counter = 0;
324      m_line_address = ( m_line_address + m_horiz_disp + 1 ) & 0xffff;
325   }
326   else
327   {
328      m_raster_counter = ( m_raster_counter + 1 ) & 0x1F;
329   }
461330
331   m_line_counter = ( m_line_counter + 1 ) & 0x3ff;
462332
463static TIMER_CALLBACK( hsync_off_timer_cb )
464{
465   device_t *device = (device_t *)ptr;
466   crtc_ega_t *crtc_ega = get_safe_token(device);
333   /* Check if we've reached the end of active display */
334   if ( m_line_counter == m_vert_disp_end )
335   {
336      m_line_enable_ff = false;
337   }
467338
468   /* call the callback function -- we know it exists */
469   crtc_ega->intf->on_hsync_changed(device, FALSE);
339   /* Check if VSYNC should be enabled */
340   if ( m_line_counter == m_vert_retr_start )
341   {
342      m_vsync_width_counter = 0;
343      m_vsync_ff = 1;
470344
471   update_hsync_changed_timers(crtc_ega);
472}
345      new_vsync = TRUE;
346   }
473347
348   /* Check if we have reached the end of the vertical area */
349   if ( m_line_counter == m_vert_total )
350   {
351      m_line_counter = 0;
352      m_line_address = m_disp_start_addr;
353      m_line_enable_ff = true;
354      set_vblank( FALSE );
355      /* also update the cursor state now */
356      update_cursor_state();
474357
475static TIMER_CALLBACK( vblank_on_timer_cb )
476{
477   device_t *device = (device_t *)ptr;
478   crtc_ega_t *crtc_ega = get_safe_token(device);
358      if (m_screen != NULL)
359         m_screen->reset_origin();
360   }
479361
480   /* call the callback function -- we know it exists */
481   crtc_ega->intf->on_vblank_changed(device, TRUE);
362   if ( m_line_enable_ff )
363   {
364      /* Schedule DE off signal change */
365      m_de_off_timer->adjust(attotime::from_ticks( m_horiz_disp + 1, m_clock ));
482366
483   update_vblank_changed_timers(crtc_ega);
484}
367      /* Is cursor visible on this line? */
368      if ( m_cursor_state &&
369         (m_raster_counter >= (m_cursor_start_ras & 0x1f)) &&
370         (m_raster_counter <= m_cursor_end_ras) &&
371         (m_cursor_addr >= m_line_address) &&
372         (m_cursor_addr < (m_line_address + m_horiz_disp + 1)) )
373      {
374         m_cursor_x = m_cursor_addr - m_line_address;
485375
376         /* Schedule CURSOR ON signal */
377         m_cur_on_timer->adjust( attotime::from_ticks( m_cursor_x, m_clock ) );
378      }
379   }
486380
487static TIMER_CALLBACK( vblank_off_timer_cb )
488{
489   device_t *device = (device_t *)ptr;
490   crtc_ega_t *crtc_ega = get_safe_token(device);
381   /* Schedule HSYNC on signal */
382   m_hsync_on_timer->adjust( attotime::from_ticks( m_horiz_blank_start, m_clock ) );
491383
492   /* call the callback function -- we know it exists */
493   crtc_ega->intf->on_vblank_changed(device, FALSE);
384   /* Set VBlank signal */
385   if ( m_line_counter == m_vert_disp_end + 1 )
386   {
387      set_vblank( TRUE );
388   }
494389
495   update_vblank_changed_timers(crtc_ega);
390   /* Schedule our next callback */
391   m_line_timer->adjust( attotime::from_ticks( m_horiz_char_total + 2, m_clock ) );
392
393   /* Set VSYNC and DE signals */
394   set_vsync( new_vsync );
395   set_de( m_line_enable_ff ? TRUE : FALSE );
496396}
497397
498398
499
500UINT16 crtc_ega_get_ma(device_t *device)
399void crtc_ega_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
501400{
502   UINT16 ret;
503   crtc_ega_t *crtc_ega = get_safe_token(device);
504
505   if (crtc_ega->has_valid_parameters)
401   switch (id)
506402   {
507      /* clamp Y/X to the visible region */
508      int y = crtc_ega->screen->vpos();
509      int x = crtc_ega->screen->hpos();
403   case TIMER_LINE:
404      handle_line_timer();
405      break;
510406
511      /* since the MA counter stops in the blanking regions, if we are in a
512           VBLANK, both X and Y are at their max */
513      if ((y > crtc_ega->max_visible_y) || (x > crtc_ega->max_visible_x))
514         x = crtc_ega->max_visible_x;
407   case TIMER_DE_OFF:
408      set_de( FALSE );
409      break;
515410
516      if (y > crtc_ega->max_visible_y)
517         y = crtc_ega->max_visible_y;
411   case TIMER_CUR_ON:
412      set_cur( TRUE );
518413
519      ret = (crtc_ega->disp_start_addr +
520           (y / (crtc_ega->max_ras_addr + 1)) * ( crtc_ega->horiz_disp + 1 ) +
521           (x / crtc_ega->hpixels_per_column)) & 0x3fff;
522   }
523   else
524      ret = 0;
414      /* Schedule CURSOR off signal */
415      m_cur_off_timer->adjust( attotime::from_ticks( 1, m_clock ) );
416      break;
525417
526   return ret;
527}
418   case TIMER_CUR_OFF:
419      set_cur( FALSE );
420      break;
528421
422   case TIMER_HSYNC_ON:
423      {
424         INT8 hsync_width = ( 0x20 | m_horiz_blank_end ) - ( m_horiz_blank_start & 0x1f );
529425
530UINT8 crtc_ega_get_ra(device_t *device)
531{
532   UINT8 ret;
533   crtc_ega_t *crtc_ega = get_safe_token(device);
426         if ( hsync_width <= 0 )
427         {
428            hsync_width += 0x20;
429         }
534430
535   if (crtc_ega->has_valid_parameters)
536   {
537      /* get the current vertical raster position and clamp it to the visible region */
538      int y = crtc_ega->screen->vpos();
431         m_hsync_width_counter = 0;
432         set_hsync( TRUE );
539433
540      if (y > crtc_ega->max_visible_y)
541         y = crtc_ega->max_visible_y;
434         /* Schedule HSYNC off signal */
435         m_hsync_off_timer->adjust( attotime::from_ticks( hsync_width, m_clock ) );
436      }
437      break;
542438
543      ret = y % (crtc_ega->max_ras_addr + 1);
544   }
545   else
546      ret = 0;
439   case TIMER_HSYNC_OFF:
440      set_hsync( FALSE );
441      break;
547442
548   return ret;
443   case TIMER_LIGHT_PEN_LATCH:
444      m_light_pen_addr = get_ma();
445      m_light_pen_latched = true;
446      break;
447   }
549448}
550449
551450
552static TIMER_CALLBACK( light_pen_latch_timer_cb )
451UINT16 crtc_ega_device::get_ma()
553452{
554   device_t *device = (device_t *)ptr;
555   crtc_ega_t *crtc_ega = get_safe_token(device);
453   update_counters();
556454
557   crtc_ega->light_pen_addr = crtc_ega_get_ma(device);
558   crtc_ega->light_pen_latched = TRUE;
455   return m_line_address + m_character_counter;
559456}
560457
561458
562void crtc_ega_assert_light_pen_input(device_t *device)
459UINT8 crtc_ega_device::get_ra()
563460{
564   int y, x;
565   int char_x;
461   return m_raster_counter;
462}
566463
567   crtc_ega_t *crtc_ega = get_safe_token(device);
568464
569   if (crtc_ega->has_valid_parameters)
570   {
571      /* get the current pixel coordinates */
572      y = crtc_ega->screen->vpos();
573      x = crtc_ega->screen->hpos();
574
575      /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */
576      char_x = x / crtc_ega->hpixels_per_column;
577      x = (char_x + 1) * crtc_ega->hpixels_per_column;
578
579      /* adjust if we are passed the boundaries of the screen */
580      if (x == crtc_ega->horiz_pix_total)
581      {
582         y = y + 1;
583         x = 0;
584
585         if (y == crtc_ega->vert_pix_total)
586            y = 0;
587      }
588
589      /* set the timer that will latch the display address into the light pen registers */
590      crtc_ega->light_pen_latch_timer->adjust(crtc_ega->screen->time_until_pos(y, x));
591   }
465void crtc_ega_device::assert_light_pen_input()
466{
467   /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */
468   /* set the timer that will latch the display address into the light pen registers */
469   m_light_pen_latch_timer->adjust(attotime::from_ticks( 1, m_clock ));
592470}
593471
594472
595void crtc_ega_set_clock(device_t *device, int clock)
473void crtc_ega_device::set_clock(int clock)
596474{
597   crtc_ega_t *crtc_ega = get_safe_token(device);
598
599475   /* validate arguments */
600476   assert(clock > 0);
601477
602   if (clock != crtc_ega->clock)
478   if (clock != m_clock)
603479   {
604      crtc_ega->clock = clock;
605      recompute_parameters(crtc_ega, FALSE);
480      m_clock = clock;
481      recompute_parameters(true);
606482   }
607483}
608484
609485
610void crtc_ega_set_hpixels_per_column(device_t *device, int hpixels_per_column)
486void crtc_ega_device::set_hpixels_per_column(int hpixels_per_column)
611487{
612   crtc_ega_t *crtc_ega = get_safe_token(device);
613
614488   /* validate arguments */
615489   assert(hpixels_per_column > 0);
616490
617   if (hpixels_per_column != crtc_ega->hpixels_per_column)
491   if (hpixels_per_column != m_hpixels_per_column)
618492   {
619      crtc_ega->hpixels_per_column = hpixels_per_column;
620      recompute_parameters(crtc_ega, FALSE);
493      m_hpixels_per_column = hpixels_per_column;
494      recompute_parameters(true);
621495   }
622496}
623497
624498
625static void update_cursor_state(crtc_ega_t *crtc_ega)
499void crtc_ega_device::update_cursor_state()
626500{
627501   /* save and increment cursor counter */
628   UINT8 last_cursor_blink_count = crtc_ega->cursor_blink_count;
629   crtc_ega->cursor_blink_count = crtc_ega->cursor_blink_count + 1;
502   UINT8 last_cursor_blink_count = m_cursor_blink_count;
503   m_cursor_blink_count = m_cursor_blink_count + 1;
630504
631505   /* switch on cursor blinking mode */
632   switch (crtc_ega->cursor_start_ras & 0x60)
506   switch (m_cursor_start_ras & 0x60)
633507   {
634508      /* always on */
635      case 0x00: crtc_ega->cursor_state = TRUE; break;
509      case 0x00: m_cursor_state = true; break;
636510
637511      /* always off */
638      case 0x20: crtc_ega->cursor_state = FALSE; break;
512      case 0x20: m_cursor_state = false; break;
639513
640514      /* fast blink */
641515      case 0x40:
642         if ((last_cursor_blink_count & 0x10) != (crtc_ega->cursor_blink_count & 0x10))
516         if ((last_cursor_blink_count & 0x10) != (m_cursor_blink_count & 0x10))
643517         {
644            crtc_ega->cursor_state = !crtc_ega->cursor_state;
518            m_cursor_state = !m_cursor_state;
645519         }
646520         break;
647521
648522      /* slow blink */
649523      case 0x60:
650         if ((last_cursor_blink_count & 0x20) != (crtc_ega->cursor_blink_count & 0x20))
524         if ((last_cursor_blink_count & 0x20) != (m_cursor_blink_count & 0x20))
651525         {
652            crtc_ega->cursor_state = !crtc_ega->cursor_state;
526            m_cursor_state = !m_cursor_state;
653527         }
654528         break;
655529   }
656530}
657531
658532
659void crtc_ega_update(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect)
533UINT32 crtc_ega_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
660534{
661   crtc_ega_t *crtc_ega = get_safe_token(device);
662535   assert(bitmap.valid());
663536
664   if (crtc_ega->has_valid_parameters)
537   if (m_has_valid_parameters)
665538   {
666539      UINT16 y;
667540
668541      void *param = NULL;
669542
670      assert(crtc_ega->intf != NULL);
671      assert(crtc_ega->intf->update_row != NULL);
543      assert(m_update_row != NULL);
672544
673545      /* call the set up function if any */
674      if (crtc_ega->intf->begin_update != NULL)
675         param = crtc_ega->intf->begin_update(device, bitmap, cliprect);
546      if (m_begin_update != NULL)
547         param = m_begin_update(this, bitmap, cliprect);
676548
677549      if (cliprect.min_y == 0)
678550      {
679551         /* read the start address at the beginning of the frame */
680         crtc_ega->current_disp_addr = crtc_ega->disp_start_addr;
681
682         /* also update the cursor state now */
683         update_cursor_state(crtc_ega);
552         m_current_disp_addr = m_disp_start_addr;
684553      }
685554
686555      /* for each row in the visible region */
687556      for (y = cliprect.min_y; y <= cliprect.max_y; y++)
688557      {
689558         /* compute the current raster line */
690         UINT8 ra = y % (crtc_ega->max_ras_addr + 1);
559         UINT8 ra = y % (m_max_ras_addr + 1);
691560
692561         /* check if the cursor is visible and is on this scanline */
693         int cursor_visible = crtc_ega->cursor_state &&
694                        (ra >= (crtc_ega->cursor_start_ras & 0x1f)) &&
695                        ( (ra <= (crtc_ega->cursor_end_ras & 0x1f)) || ((crtc_ega->cursor_end_ras & 0x1f) == 0x00 )) &&
696                        (crtc_ega->cursor_addr >= crtc_ega->current_disp_addr) &&
697                        (crtc_ega->cursor_addr < (crtc_ega->current_disp_addr + ( crtc_ega->horiz_disp + 1 )));
562         int cursor_visible = m_cursor_state &&
563                        (ra >= (m_cursor_start_ras & 0x1f)) &&
564                        ( (ra <= (m_cursor_end_ras & 0x1f)) || ((m_cursor_end_ras & 0x1f) == 0x00 )) &&
565                        (m_cursor_addr >= m_current_disp_addr) &&
566                        (m_cursor_addr < (m_current_disp_addr + ( m_horiz_disp + 1 )));
698567
699568         /* compute the cursor X position, or -1 if not visible */
700         INT8 cursor_x = cursor_visible ? (crtc_ega->cursor_addr - crtc_ega->current_disp_addr) : -1;
569         INT8 cursor_x = cursor_visible ? (m_cursor_addr - m_current_disp_addr) : -1;
701570
702571         /* call the external system to draw it */
703         crtc_ega->intf->update_row(device, bitmap, cliprect, crtc_ega->current_disp_addr, ra, y, crtc_ega->horiz_disp + 1, cursor_x, param);
572         m_update_row(this, bitmap, cliprect, m_current_disp_addr, ra, y, m_horiz_disp + 1, cursor_x, param);
704573
705574         /* update MA if the last raster address */
706         if (ra == crtc_ega->max_ras_addr)
707            crtc_ega->current_disp_addr = (crtc_ega->current_disp_addr + crtc_ega->horiz_disp + 1) & 0xffff;
575         if (ra == m_max_ras_addr)
576            m_current_disp_addr = (m_current_disp_addr + m_horiz_disp + 1) & 0xffff;
708577      }
709578
710579      /* call the tear down function if any */
711      if (crtc_ega->intf->end_update != NULL)
712         crtc_ega->intf->end_update(device, bitmap, cliprect, param);
580      if (m_end_update != NULL)
581         m_end_update(this, bitmap, cliprect, param);
713582   }
714583   else
715584      logerror("Invalid crtc_ega screen parameters - display disabled!!!\n");
585
586   return 0;
716587}
717588
718589
719590/* device interface */
720static void common_start(device_t *device, int device_type)
591void crtc_ega_device::device_start()
721592{
722   crtc_ega_t *crtc_ega = get_safe_token(device);
723
724593   /* validate arguments */
725   assert(device != NULL);
726   assert(device->tag() != NULL);
727   assert(device->clock() > 0);
594   assert(m_clock > 0);
595   assert(m_hpixels_per_column > 0);
728596
729   crtc_ega->intf = (const crtc_ega_interface*)device->static_config();
730   crtc_ega->device_type = device_type;
597   /* resolve callbacks */
598   m_res_out_de_func.resolve(m_out_de_func, *this);
599   m_res_out_hsync_func.resolve(m_out_hsync_func, *this);
600   m_res_out_vsync_func.resolve(m_out_vsync_func, *this);
601   m_res_out_vblank_func.resolve(m_out_vblank_func, *this);
731602
732   if (crtc_ega->intf != NULL)
603   /* get the screen device */
604   if ( m_screen_tag != NULL )
733605   {
734      assert(crtc_ega->intf->hpixels_per_column > 0);
735
736      /* copy the initial parameters */
737      crtc_ega->clock = device->clock();
738      crtc_ega->hpixels_per_column = crtc_ega->intf->hpixels_per_column;
739
740      /* get the screen device */
741606      astring tempstring;
742      crtc_ega->screen = downcast<screen_device *>(device->machine().device(device->owner()->subtag(tempstring,crtc_ega->intf->screen_tag)));
743      assert(crtc_ega->screen != NULL);
744
745      /* create the timers */
746      if (crtc_ega->intf->on_de_changed != NULL)
747         crtc_ega->de_changed_timer = device->machine().scheduler().timer_alloc(FUNC(de_changed_timer_cb), (void *)device);
748
749      if (crtc_ega->intf->on_hsync_changed != NULL)
750      {
751         crtc_ega->hsync_on_timer = device->machine().scheduler().timer_alloc(FUNC(hsync_on_timer_cb), (void *)device);
752         crtc_ega->hsync_off_timer = device->machine().scheduler().timer_alloc(FUNC(hsync_off_timer_cb), (void *)device);
753      }
754
755      if (crtc_ega->intf->on_vsync_changed != NULL)
756      {
757         crtc_ega->vsync_on_timer = device->machine().scheduler().timer_alloc(FUNC(vsync_on_timer_cb), (void *)device);
758         crtc_ega->vsync_off_timer = device->machine().scheduler().timer_alloc(FUNC(vsync_off_timer_cb), (void *)device);
759      }
760
761      if (crtc_ega->intf->on_vblank_changed != NULL)
762      {
763         crtc_ega->vblank_on_timer = device->machine().scheduler().timer_alloc(FUNC(vblank_on_timer_cb), (void *)device);
764         crtc_ega->vblank_off_timer = device->machine().scheduler().timer_alloc(FUNC(vblank_off_timer_cb), (void *)device);
765      }
607      m_screen = downcast<screen_device *>(machine().device(siblingtag(tempstring,m_screen_tag)));
608      assert(m_screen != NULL);
766609   }
610   else
611      m_screen = NULL;
767612
768   crtc_ega->light_pen_latch_timer = device->machine().scheduler().timer_alloc(FUNC(light_pen_latch_timer_cb), (void *)device);
613   /* create the timers */
614   m_line_timer = timer_alloc(TIMER_LINE);
615   m_de_off_timer = timer_alloc(TIMER_DE_OFF);
616   m_cur_on_timer = timer_alloc(TIMER_CUR_ON);
617   m_cur_off_timer = timer_alloc(TIMER_CUR_OFF);
618   m_hsync_on_timer = timer_alloc(TIMER_HSYNC_ON);
619   m_hsync_off_timer = timer_alloc(TIMER_HSYNC_OFF);
620   m_light_pen_latch_timer = timer_alloc(TIMER_LIGHT_PEN_LATCH);
769621
770   /* register for state saving */
622   /* Use some large startup values */
623   m_horiz_char_total = 0xff;
624   m_max_ras_addr = 0x1f;
625   m_vert_total = 0x3ff;
771626
772   device->machine().save().register_postload(save_prepost_delegate(FUNC(crtc_ega_state_save_postload), crtc_ega));
773
774   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->clock);
775   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->hpixels_per_column);
776   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->register_address_latch);
777   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_char_total);
778   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_disp);
779   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_blank_start);
780   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->mode_control);
781   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_start_ras);
782   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_end_ras);
783   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->disp_start_addr);
784   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_addr);
785   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->light_pen_addr);
786   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->light_pen_latched);
787   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_state);
788   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_blink_count);
789   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_blank_end);
790   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->ena_vert_access);
791   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->de_skew);
792   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_retr_start);
793   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_retr_end);
794   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->horiz_retr_skew);
795   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->vert_total);
796   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->preset_row_scan);
797   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->byte_panning);
798   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->max_ras_addr);
799   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->scan_doubling);
800   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_disable);
801   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->cursor_skew);
802   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->vert_retr_start);
803   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->vert_retr_end);
804   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->protect);
805   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->bandwidth);
806   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->vert_disp_end);
807   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->offset);
808   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->underline_loc);
809   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->vert_blank_start);
810   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->vert_blank_end);
811   state_save_register_item(device->machine(), device->tag(), NULL, 0, crtc_ega->line_compare);
627   /* register for state saving */
628   save_item(NAME(m_hpixels_per_column));
629   save_item(NAME(m_register_address_latch));
630   save_item(NAME(m_horiz_char_total));
631   save_item(NAME(m_horiz_disp));
632   save_item(NAME(m_horiz_blank_start));
633   save_item(NAME(m_mode_control));
634   save_item(NAME(m_cursor_start_ras));
635   save_item(NAME(m_cursor_end_ras));
636   save_item(NAME(m_disp_start_addr));
637   save_item(NAME(m_cursor_addr));
638   save_item(NAME(m_light_pen_addr));
639   save_item(NAME(m_light_pen_latched));
640   save_item(NAME(m_cursor_state));
641   save_item(NAME(m_cursor_blink_count));
642   save_item(NAME(m_horiz_blank_end));
643   save_item(NAME(m_ena_vert_access));
644   save_item(NAME(m_de_skew));
645   save_item(NAME(m_horiz_retr_start));
646   save_item(NAME(m_horiz_retr_end));
647   save_item(NAME(m_horiz_retr_skew));
648   save_item(NAME(m_vert_total));
649   save_item(NAME(m_preset_row_scan));
650   save_item(NAME(m_byte_panning));
651   save_item(NAME(m_max_ras_addr));
652   save_item(NAME(m_scan_doubling));
653   save_item(NAME(m_cursor_disable));
654   save_item(NAME(m_cursor_skew));
655   save_item(NAME(m_vert_retr_start));
656   save_item(NAME(m_vert_retr_end));
657   save_item(NAME(m_protect));
658   save_item(NAME(m_bandwidth));
659   save_item(NAME(m_vert_disp_end));
660   save_item(NAME(m_offset));
661   save_item(NAME(m_underline_loc));
662   save_item(NAME(m_vert_blank_start));
663   save_item(NAME(m_vert_blank_end));
664   save_item(NAME(m_line_compare));
812665}
813666
814667
815static DEVICE_START( crtc_ega )
668void crtc_ega_device::device_reset()
816669{
817   common_start(device, TYPE_CRTC_EGA);
818}
819
820
821static DEVICE_RESET( crtc_ega )
822{
823   crtc_ega_t *crtc_ega = get_safe_token(device);
824
825670   /* internal registers other than status remain unchanged, all outputs go low */
826   if (crtc_ega->intf != NULL)
827   {
828      if (crtc_ega->intf->on_de_changed != NULL)
829         crtc_ega->intf->on_de_changed(device, FALSE);
671   if ( !m_res_out_de_func.isnull() )
672      m_res_out_de_func( FALSE );
830673
831      if (crtc_ega->intf->on_hsync_changed != NULL)
832         crtc_ega->intf->on_hsync_changed(device, FALSE);
674   if ( !m_res_out_hsync_func.isnull() )
675      m_res_out_hsync_func( FALSE );
833676
834      if (crtc_ega->intf->on_vsync_changed != NULL)
835         crtc_ega->intf->on_vsync_changed(device, FALSE);
836   }
677   if ( !m_res_out_vsync_func.isnull() )
678      m_res_out_vsync_func( FALSE );
837679
838   crtc_ega->light_pen_latched = FALSE;
839}
680   if ( !m_res_out_vblank_func.isnull() )
681      m_res_out_vblank_func( FALSE );
840682
841
842DEVICE_GET_INFO( crtc_ega )
843{
844   switch (state)
683   if ( ! m_line_timer->enabled( ) )
845684   {
846      /* --- the following bits of info are returned as 64-bit signed integers --- */
847      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(crtc_ega_t);               break;
848      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
685      m_line_timer->adjust( attotime::from_ticks( m_horiz_char_total + 2, m_clock ) );
686   }
849687
850      /* --- the following bits of info are returned as pointers to data or functions --- */
851      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(crtc_ega);   break;
852      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
853      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(crtc_ega);   break;
688   m_light_pen_latched = false;
854689
855      /* --- the following bits of info are returned as NULL-terminated strings --- */
856      case DEVINFO_STR_NAME:                     strcpy(info->s, "IBM EGA CRTC");               break;
857      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "EGA CRTC");                  break;
858      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.00");                     break;
859      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
860      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team"); break;
861   }
690   m_cursor_addr = 0;
691   m_line_address = 0;
692   m_horiz_disp = 0;
693   m_cursor_x = 0;
862694}
863695
864#if 0
865DEVICE_GET_INFO( crtc_vga )
866{
867   switch (state)
868   {
869      default:                              DEVICE_GET_INFO_CALL( crtc_ega );         break;
870   }
871}
872#endif
873
874DEFINE_LEGACY_DEVICE(CRTC_EGA, crtc_ega);
src/mess/video/crtc_ega.h
r15502r15503
77#ifndef __CRTC_EGA__
88#define __CRTC_EGA__
99
10#include "emu.h"
11#include "machine/devhelpr.h"
1012
11DECLARE_LEGACY_DEVICE(CRTC_EGA, crtc_ega);
13#define CRTC_EGA_INTERFACE(name) \
14   const crtc_ega_interface (name) =
1215
1316#define MCFG_CRTC_EGA_ADD(_tag, _clock, _intrf) \
1417   MCFG_DEVICE_ADD(_tag, CRTC_EGA, _clock) \
1518   MCFG_DEVICE_CONFIG(_intrf)
1619
20
21class crtc_ega_device;
22
1723/* callback definitions */
18typedef void * (*crtc_ega_begin_update_func)(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect);
19#define CRTC_EGA_BEGIN_UPDATE(name)   void *name(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect)
24typedef void * (*crtc_ega_begin_update_func)(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect);
25#define CRTC_EGA_BEGIN_UPDATE(name)   void *name(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect)
2026
21typedef void (*crtc_ega_update_row_func)(device_t *device, bitmap_ind16 &bitmap,
27typedef void (*crtc_ega_update_row_func)(crtc_ega_device *device, bitmap_ind16 &bitmap,
2228                              const rectangle &cliprect, UINT16 ma, UINT8 ra,
2329                              UINT16 y, UINT8 x_count, INT8 cursor_x, void *param);
24#define CRTC_EGA_UPDATE_ROW(name)      void name(device_t *device, bitmap_ind16 &bitmap,   \
30#define CRTC_EGA_UPDATE_ROW(name)      void name(crtc_ega_device *device, bitmap_ind16 &bitmap,   \
2531                                   const rectangle &cliprect, UINT16 ma, UINT8 ra,               \
2632                                   UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
2733
28typedef void (*crtc_ega_end_update_func)(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, void *param);
29#define CRTC_EGA_END_UPDATE(name)      void name(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, void *param)
34typedef void (*crtc_ega_end_update_func)(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect, void *param);
35#define CRTC_EGA_END_UPDATE(name)      void name(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect, void *param)
3036
31typedef void (*crtc_ega_on_de_changed_func)(device_t *device, int display_enabled);
32#define CRTC_EGA_ON_DE_CHANGED(name)   void name(device_t *device, int display_enabled)
3337
34typedef void (*crtc_ega_on_hsync_changed_func)(device_t *device, int hsync);
35#define CRTC_EGA_ON_HSYNC_CHANGED(name)   void name(device_t *device, int hsync)
36
37typedef void (*crtc_ega_on_vsync_changed_func)(device_t *device, int vsync);
38#define CRTC_EGA_ON_VSYNC_CHANGED(name)   void name(device_t *device, int vsync)
39
40typedef void (*crtc_ega_on_vblank_changed_func)(device_t *device, int vblank);
41#define CRTC_EGA_ON_VBLANK_CHANGED(name) void name(device_t *device, int vblank)
42
43
4438/* interface */
4539typedef struct _crtc_ega_interface crtc_ega_interface;
4640struct _crtc_ega_interface
4741{
48   const char *screen_tag;      /* screen we are acting on */
49   int hpixels_per_column;      /* number of pixels per video memory address */
42   const char *m_screen_tag;      /* screen we are acting on */
43   int m_hpixels_per_column;      /* number of pixels per video memory address */
5044
5145   /* if specified, this gets called before any pixel update,
5246       optionally return a pointer that will be passed to the
5347       update and tear down callbacks */
54   crtc_ega_begin_update_func      begin_update;
48   crtc_ega_begin_update_func      m_begin_update;
5549
5650   /* this gets called for every row, the driver must output
5751       x_count * hpixels_per_column pixels.
5852       cursor_x indicates the character position where the cursor is, or -1
5953       if there is no cursor on this row */
60   crtc_ega_update_row_func      update_row;
54   crtc_ega_update_row_func      m_update_row;
6155
6256   /* if specified, this gets called after all row updating is complete */
63   crtc_ega_end_update_func         end_update;
57   crtc_ega_end_update_func         m_end_update;
6458
6559   /* if specified, this gets called for every change of the disply enable signal */
66   crtc_ega_on_de_changed_func      on_de_changed;
60   devcb_write_line   m_out_de_func;
6761
6862   /* if specified, this gets called for every change of the HSYNC signal */
69   crtc_ega_on_hsync_changed_func   on_hsync_changed;
63   devcb_write_line   m_out_hsync_func;
7064
7165   /* if specified, this gets called for every change of the VSYNC signal */
72   crtc_ega_on_vsync_changed_func   on_vsync_changed;
66   devcb_write_line   m_out_vsync_func;
7367
74   /* if specificed, this gets called for every change of the VBLANK signal */
75   crtc_ega_on_vblank_changed_func   on_vblank_changed;
68   devcb_write_line   m_out_vblank_func;
7669};
7770
78/* select one of the registers for reading or writing */
79WRITE8_DEVICE_HANDLER( crtc_ega_address_w );
8071
81/* read from the currently selected register */
82READ8_DEVICE_HANDLER( crtc_ega_register_r );
72class crtc_ega_device :   public device_t,
73                  public crtc_ega_interface
74{
75public:
76   crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8377
84/* write to the currently selected register */
85WRITE8_DEVICE_HANDLER( crtc_ega_register_w );
78   /* select one of the registers for reading or writing */
79   DECLARE_WRITE8_MEMBER( address_w );
8680
87/* return the current value on the MA0-MA15 pins */
88UINT16 crtc_ega_get_ma(device_t *device);
81   /* read from the currently selected register */
82   DECLARE_READ8_MEMBER( register_r );
8983
90/* return the current value on the RA0-RA4 pins */
91UINT8 crtc_ega_get_ra(device_t *device);
84   /* write to the currently selected register */
85   DECLARE_WRITE8_MEMBER( register_w );
9286
93/* simulates the LO->HI clocking of the light pen pin (pin 3) */
94void crtc_ega_assert_light_pen_input(device_t *device);
87   /* return the current value on the MA0-MA15 pins */
88   UINT16 get_ma();
9589
96/* set the clock (pin 21) of the chip */
97void crtc_ega_set_clock(device_t *device, int clock);
90   /* return the current value on the RA0-RA4 pins */
91   UINT8 get_ra();
9892
99/* set number of pixels per video memory address */
100void crtc_ega_set_hpixels_per_column(device_t *device, int hpixels_per_column);
93   /* simulates the LO->HI clocking of the light pen pin */
94   void assert_light_pen_input();
10195
102/* updates the screen -- this will call begin_update(),
103   followed by update_row() reapeatedly and after all row
104   updating is complete, end_update() */
105void crtc_ega_update(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect);
96   /* set the clock of the chip */
97   void set_clock(int clock);
10698
99   /* set number of pixels per video memory address */
100   void set_hpixels_per_column(int hpixels_per_column);
107101
102   /* updates the screen -- this will call begin_update(), */
103   /* followed by update_row() reapeatedly and after all row */
104   /* updating is complete, end_update() */
105   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
106
107protected:
108   // device-level overrides
109   virtual void device_config_complete();
110   virtual void device_start();
111   virtual void device_reset();
112   virtual void device_post_load();
113   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
114
115private:
116   screen_device *m_screen;
117
118   devcb_resolved_write_line   m_res_out_de_func;
119   devcb_resolved_write_line   m_res_out_cur_func;
120   devcb_resolved_write_line   m_res_out_hsync_func;
121   devcb_resolved_write_line   m_res_out_vsync_func;
122   devcb_resolved_write_line   m_res_out_vblank_func;
123
124   /* ega/vga register file */
125   UINT8   m_horiz_char_total;   /* 0x00 */
126   UINT8   m_horiz_disp;         /* 0x01 */
127   UINT8   m_horiz_blank_start;   /* 0x02 */
128   UINT8   m_horiz_blank_end;   /* 0x03/0x05 */
129   UINT8   m_ena_vert_access;   /* 0x03 */
130   UINT8   m_de_skew;         /* 0x03 */
131   UINT8   m_horiz_retr_start;   /* 0x04 */
132   UINT8   m_horiz_retr_end;      /* 0x05 */
133   UINT8   m_horiz_retr_skew;   /* 0x05 */
134   UINT16   m_vert_total;         /* 0x06/0x07 */
135   UINT8   m_preset_row_scan;   /* 0x08 */
136   UINT8   m_byte_panning;      /* 0x08 */
137   UINT8   m_max_ras_addr;      /* 0x09 */
138   UINT8   m_scan_doubling;      /* 0x09 */
139   UINT8   m_cursor_start_ras;   /* 0x0a */
140   UINT8   m_cursor_disable;      /* 0x0a */
141   UINT8   m_cursor_end_ras;      /* 0x0b */
142   UINT8   m_cursor_skew;      /* 0x0b */
143   UINT16   m_disp_start_addr;   /* 0x0c/0x0d */
144   UINT16   m_cursor_addr;      /* 0x0e/0x0f */
145   UINT16   m_light_pen_addr;      /* 0x10/0x11 */
146   UINT16   m_vert_retr_start;   /* 0x10/0x07 */
147   UINT8   m_vert_retr_end;      /* 0x11 */
148   UINT8   m_protect;         /* 0x11 */
149   UINT8   m_bandwidth;         /* 0x11 */
150   UINT16   m_vert_disp_end;      /* 0x12/0x07 */
151   UINT8   m_offset;            /* 0x13 */
152   UINT8   m_underline_loc;      /* 0x14 */
153   UINT16   m_vert_blank_start;   /* 0x15/0x07/0x09 */
154   UINT8   m_vert_blank_end;      /* 0x16 */
155   UINT8   m_mode_control;      /* 0x17 */
156   UINT16   m_line_compare;      /* 0x18/0x07/0x09 */
157
158   /* other internal state */
159   UINT8   m_register_address_latch;
160   UINT8   m_hpixels_per_column;
161   bool   m_cursor_state;   /* 0 = off, 1 = on */
162   UINT8   m_cursor_blink_count;
163
164   /* output signals */
165   int      m_cur;
166   int      m_hsync;
167   int      m_vsync;
168   int      m_vblank;
169   int      m_de;
170
171   /* internal counters */
172   UINT8   m_character_counter;
173   UINT8   m_hsync_width_counter;
174   UINT16   m_line_counter;
175   UINT8   m_raster_counter;
176   UINT8   m_vsync_width_counter;
177   bool   m_line_enable_ff;      /* Internal flip flop which is set when the line_counter is reset and reset when vert_disp is reached */
178   UINT8   m_vsync_ff;
179   UINT8   m_adjust_active;
180   UINT16   m_line_address;
181   INT16   m_cursor_x;
182
183   /* timers */
184   static const device_timer_id TIMER_LINE = 0;
185   static const device_timer_id TIMER_DE_OFF = 1;
186   static const device_timer_id TIMER_CUR_ON = 2;
187   static const device_timer_id TIMER_CUR_OFF = 3;
188   static const device_timer_id TIMER_HSYNC_ON = 4;
189   static const device_timer_id TIMER_HSYNC_OFF = 5;
190   static const device_timer_id TIMER_LIGHT_PEN_LATCH = 6;
191
192   emu_timer *m_line_timer;
193   emu_timer *m_de_off_timer;
194   emu_timer *m_cur_on_timer;
195   emu_timer *m_cur_off_timer;
196   emu_timer *m_hsync_on_timer;
197   emu_timer *m_hsync_off_timer;
198   emu_timer *m_light_pen_latch_timer;
199
200   /* computed values - do NOT state save these! */
201   UINT16   m_horiz_pix_total;
202   UINT16   m_vert_pix_total;
203   UINT16   m_max_visible_x;
204   UINT16   m_max_visible_y;
205   UINT16   m_hsync_on_pos;
206   UINT16   m_hsync_off_pos;
207   UINT16   m_vsync_on_pos;
208   UINT16   m_vsync_off_pos;
209   UINT16  m_current_disp_addr;   /* the display address currently drawn */
210   UINT8   m_light_pen_latched;
211   bool   m_has_valid_parameters;
212
213   void recompute_parameters(bool postload);
214   void update_counters();
215   void set_de(int state);
216   void set_hsync(int state);
217   void set_vsync(int state);
218   void set_vblank(int state);
219   void set_cur(int state);
220   void handle_line_timer();
221   void update_cursor_state();
222};
223
224extern const device_type CRTC_EGA;
225
108226#endif

Previous 15994 Revisions Next


© 1998-2018 The MESS Team