Previous 199869 Revisions Next

r29505 Wednesday 9th April, 2014 at 22:17:40 UTC by Fabio Priuli
crtc_ega: updated to use devcb2, inline configs and delegates. nw.
[src/emu/bus/isa]ega.c ega.h
[src/emu/video]crtc_ega.c crtc_ega.h

trunk/src/emu/video/crtc_ega.c
r29504r29505
1616const device_type CRTC_EGA = &device_creator<crtc_ega_device>;
1717
1818
19void crtc_ega_device::device_config_complete()
20{
21   const crtc_ega_interface *intf = reinterpret_cast<const crtc_ega_interface *>(static_config());
22
23   if ( intf != NULL )
24   {
25      *static_cast<crtc_ega_interface *>(this) = *intf;
26   }
27   else
28   {
29      m_hpixels_per_column = 0;
30      m_begin_update = NULL;
31      m_update_row = NULL;
32      m_end_update = NULL;
33      memset(&m_out_de_func, 0, sizeof(m_out_de_func));
34      memset(&m_out_hsync_func, 0, sizeof(m_out_hsync_func));
35      memset(&m_out_vsync_func, 0, sizeof(m_out_vsync_func));
36      memset(&m_out_vblank_func, 0, sizeof(m_out_vblank_func));
37   }
38}
39
40
4119crtc_ega_device::crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
4220   : device_t(mconfig, CRTC_EGA, "crtc_EGA", tag, owner, clock, "crtc_ega", __FILE__),
43      device_video_interface(mconfig, *this, false)
21      device_video_interface(mconfig, *this, false),
22      m_res_out_de_cb(*this),
23      m_res_out_hsync_cb(*this),
24      m_res_out_vsync_cb(*this),
25      m_res_out_vblank_cb(*this),
26      m_hpixels_per_column(0)
4427{
4528}
4629
r29504r29505
239222
240223void crtc_ega_device::set_de(int state)
241224{
242   if ( m_de != state )
225   if (m_de != state)
243226   {
244227      m_de = state;
245228
246      if ( !m_res_out_de_func.isnull() )
247         m_res_out_de_func( m_de );
229      if (!m_res_out_de_cb.isnull())
230         m_res_out_de_cb(m_de);
248231   }
249232}
250233
251234
252235void crtc_ega_device::set_hsync(int state)
253236{
254   if ( m_hsync != state )
237   if (m_hsync != state)
255238   {
256239      m_hsync = state;
257240
258      if ( !m_res_out_hsync_func.isnull() )
259         m_res_out_hsync_func( m_hsync );
241      if (!m_res_out_hsync_cb.isnull())
242         m_res_out_hsync_cb(m_hsync);
260243   }
261244}
262245
263246
264247void crtc_ega_device::set_vsync(int state)
265248{
266   if ( m_vsync != state )
249   if (m_vsync != state)
267250   {
268251      m_vsync = state;
269252
270      if ( !m_res_out_vsync_func.isnull() )
271         m_res_out_vsync_func( m_vsync );
253      if (!m_res_out_vsync_cb.isnull())
254         m_res_out_vsync_cb(m_vsync);
272255   }
273256}
274257
275258
276259void crtc_ega_device::set_vblank(int state)
277260{
278   if ( m_vblank != state )
261   if (m_vblank != state)
279262   {
280263      m_vblank = state;
281264
282      if ( !m_res_out_vblank_func.isnull() )
283         m_res_out_vblank_func( m_vblank );
265      if (!m_res_out_vblank_cb.isnull())
266         m_res_out_vblank_cb(m_vblank);
284267   }
285268}
286269
287270
288271void crtc_ega_device::set_cur(int state)
289272{
290   if ( m_cur != state )
273   if (m_cur != state)
291274   {
292275      m_cur = state;
293276
294//      if ( !m_res_out_cur_func.isnull() )
295//          m_res_out_cur_func( m_cur );
277//      if (!m_res_out_cur_cb.isnull())
278//          m_res_out_cur_cb(m_cur);
296279   }
297280}
298281
r29504r29505
538521   {
539522      UINT16 y;
540523
541      void *param = NULL;
524      assert(!m_row_update_cb.isnull() != NULL);
542525
543      assert(m_update_row != NULL);
544
545526      /* call the set up function if any */
546      if (m_begin_update != NULL)
547         param = m_begin_update(this, bitmap, cliprect);
527      if (!m_begin_update_cb.isnull())
528         m_begin_update_cb(bitmap, cliprect);
548529
549530      if (cliprect.min_y == 0)
550531      {
r29504r29505
569550         INT8 cursor_x = cursor_visible ? (m_cursor_addr - m_current_disp_addr) : -1;
570551
571552         /* call the external system to draw it */
572         m_update_row(this, bitmap, cliprect, m_current_disp_addr, ra, y, m_horiz_disp + 1, cursor_x, param);
553         m_row_update_cb(bitmap, cliprect, m_current_disp_addr, ra, y, m_horiz_disp + 1, cursor_x);
573554
574555         /* update MA if the last raster address */
575556         if (ra == m_max_ras_addr)
r29504r29505
577558      }
578559
579560      /* call the tear down function if any */
580      if (m_end_update != NULL)
581         m_end_update(this, bitmap, cliprect, param);
561      if (!m_end_update_cb.isnull())
562         m_end_update_cb(bitmap, cliprect);
582563   }
583564   else
584565      logerror("Invalid crtc_ega screen parameters - display disabled!!!\n");
r29504r29505
595576   assert(m_hpixels_per_column > 0);
596577
597578   /* 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);
579   m_res_out_de_cb.resolve();
580   m_res_out_hsync_cb.resolve();
581   m_res_out_vsync_cb.resolve();
582   m_res_out_vblank_cb.resolve();
602583
584   /* bind delegates */
585   m_begin_update_cb.bind_relative_to(*owner());
586   m_row_update_cb.bind_relative_to(*owner());
587   m_end_update_cb.bind_relative_to(*owner());
588
603589   /* create the timers */
604590   m_line_timer = timer_alloc(TIMER_LINE);
605591   m_de_off_timer = timer_alloc(TIMER_DE_OFF);
r29504r29505
699685void crtc_ega_device::device_reset()
700686{
701687   /* internal registers other than status remain unchanged, all outputs go low */
702   if ( !m_res_out_de_func.isnull() )
703      m_res_out_de_func( FALSE );
688   if (!m_res_out_de_cb.isnull())
689      m_res_out_de_cb(false);
704690
705   if ( !m_res_out_hsync_func.isnull() )
706      m_res_out_hsync_func( FALSE );
691   if (!m_res_out_hsync_cb.isnull())
692      m_res_out_hsync_cb(false);
707693
708   if ( !m_res_out_vsync_func.isnull() )
709      m_res_out_vsync_func( FALSE );
694   if (!m_res_out_vsync_cb.isnull())
695      m_res_out_vsync_cb(false);
710696
711   if ( !m_res_out_vblank_func.isnull() )
712      m_res_out_vblank_func( FALSE );
697   if (!m_res_out_vblank_cb.isnull())
698      m_res_out_vblank_cb(false);
713699
714   if ( ! m_line_timer->enabled( ) )
700   if (!m_line_timer->enabled())
715701   {
716702      m_line_timer->adjust( attotime::from_ticks( m_horiz_char_total + 2, m_clock ) );
717703   }
trunk/src/emu/video/crtc_ega.h
r29504r29505
99
1010#include "emu.h"
1111
12#define CRTC_EGA_INTERFACE(name) \
13   const crtc_ega_interface (name) =
12/* callback definitions */
13typedef device_delegate<void (bitmap_ind16 &bitmap, const rectangle &cliprect)> crtc_ega_begin_update_delegate;
1414
15#define MCFG_CRTC_EGA_ADD(_tag, _clock, _intrf) \
16   MCFG_DEVICE_ADD(_tag, CRTC_EGA, _clock) \
17   MCFG_DEVICE_CONFIG(_intrf)
15typedef device_delegate<void (bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra,
16                              UINT16 y, UINT8 x_count, INT8 cursor_x)> crtc_ega_row_update_delegate;
1817
19#define MCFG_CRTC_EGA_SET_SCREEN MCFG_VIDEO_SET_SCREEN
18typedef device_delegate<void (bitmap_ind16 &bitmap, const rectangle &cliprect)> crtc_ega_end_update_delegate;
2019
2120
22class crtc_ega_device;
21#define CRTC_EGA_BEGIN_UPDATE(_name) void _name(bitmap_ind16 &bitmap, const rectangle &cliprect)
22#define CRTC_EGA_ROW_UPDATE(_name)   void _name(bitmap_ind16 &bitmap,    \
23                                    const rectangle &cliprect, UINT16 ma, UINT8 ra,                 \
24                                    UINT16 y, UINT8 x_count, INT8 cursor_x)
25#define CRTC_EGA_END_UPDATE(_name)   void _name(bitmap_ind16 &bitmap, const rectangle &cliprect)
2326
24/* callback definitions */
25typedef void * (*crtc_ega_begin_update_func)(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect);
26#define CRTC_EGA_BEGIN_UPDATE(name) void *name(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect)
2727
28typedef void (*crtc_ega_update_row_func)(crtc_ega_device *device, bitmap_ind16 &bitmap,
29                              const rectangle &cliprect, UINT16 ma, UINT8 ra,
30                              UINT16 y, UINT8 x_count, INT8 cursor_x, void *param);
31#define CRTC_EGA_UPDATE_ROW(name)       void name(crtc_ega_device *device, bitmap_ind16 &bitmap,    \
32                                    const rectangle &cliprect, UINT16 ma, UINT8 ra,                 \
33                                    UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
3428
35typedef void (*crtc_ega_end_update_func)(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect, void *param);
36#define CRTC_EGA_END_UPDATE(name)       void name(crtc_ega_device *device, bitmap_ind16 &bitmap, const rectangle &cliprect, void *param)
29#define MCFG_CRTC_EGA_SET_SCREEN MCFG_VIDEO_SET_SCREEN
3730
31#define MCFG_CRTC_EGA_BEGIN_UPDATE_CB(_class, _method) \
32   crtc_ega_device::set_begin_update_callback(*device, crtc_ega_begin_update_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
3833
39/* interface */
40struct crtc_ega_interface
41{
42   int m_hpixels_per_column;       /* number of pixels per video memory address */
34#define MCFG_CRTC_EGA_ROW_UPDATE_CB(_class, _method) \
35   crtc_ega_device::set_row_update_callback(*device, crtc_ega_row_update_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
4336
44   /* if specified, this gets called before any pixel update,
45      optionally return a pointer that will be passed to the
46      update and tear down callbacks */
47   crtc_ega_begin_update_func      m_begin_update;
37#define MCFG_CRTC_EGA_END_UPDATE_CB(_class, _method) \
38   crtc_ega_device::set_end_update_callback(*device, crtc_ega_end_update_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
4839
49   /* this gets called for every row, the driver must output
50      x_count * hpixels_per_column pixels.
51      cursor_x indicates the character position where the cursor is, or -1
52      if there is no cursor on this row */
53   crtc_ega_update_row_func        m_update_row;
40#define MCFG_CRTC_EGA_HPIXELS_PER_COLUMN(_pix) \
41   crtc_ega_device::set_hpixels_per_column(*device, _pix);
5442
55   /* if specified, this gets called after all row updating is complete */
56   crtc_ega_end_update_func            m_end_update;
43#define MCFG_CRTC_EGA_RES_OUT_DE_CB(_devcb) \
44   devcb = &crtc_ega_device::set_res_out_de_callback(*device, DEVCB2_##_devcb);
5745
58   /* if specified, this gets called for every change of the disply enable signal */
59   devcb_write_line    m_out_de_func;
46#define MCFG_CRTC_EGA_RES_OUT_HSYNC_CB(_devcb) \
47   devcb = &crtc_ega_device::set_res_out_hsync_callback(*device, DEVCB2_##_devcb);
6048
61   /* if specified, this gets called for every change of the HSYNC signal */
62   devcb_write_line    m_out_hsync_func;
49#define MCFG_CRTC_EGA_RES_OUT_VSYNC_CB(_devcb) \
50   devcb = &crtc_ega_device::set_res_out_vsync_callback(*device, DEVCB2_##_devcb);
6351
64   /* if specified, this gets called for every change of the VSYNC signal */
65   devcb_write_line    m_out_vsync_func;
52#define MCFG_CRTC_EGA_RES_OUT_VBLANK_CB(_devcb) \
53   devcb = &crtc_ega_device::set_res_out_vblank_callback(*device, DEVCB2_##_devcb);
6654
67   devcb_write_line    m_out_vblank_func;
68};
6955
70
7156class crtc_ega_device : public device_t,
72                  public device_video_interface,
73                  public crtc_ega_interface
57                  public device_video_interface
7458{
7559public:
7660   crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7761
62   template<class _Object> static devcb2_base &set_res_out_de_callback(device_t &device, _Object object)
63                  { return downcast<crtc_ega_device &>(device).m_res_out_de_cb.set_callback(object); }
64   template<class _Object> static devcb2_base &set_res_out_hsync_callback(device_t &device, _Object object)
65                  { return downcast<crtc_ega_device &>(device).m_res_out_hsync_cb.set_callback(object); }
66   template<class _Object> static devcb2_base &set_res_out_vsync_callback(device_t &device, _Object object)
67                  { return downcast<crtc_ega_device &>(device).m_res_out_vsync_cb.set_callback(object); }
68   template<class _Object> static devcb2_base &set_res_out_vblank_callback(device_t &device, _Object object)
69                  { return downcast<crtc_ega_device &>(device).m_res_out_vblank_cb.set_callback(object); }
70
71   static void set_begin_update_callback(device_t &device, crtc_ega_begin_update_delegate callback) { downcast<crtc_ega_device &>(device).m_begin_update_cb = callback; }
72   static void set_row_update_callback(device_t &device, crtc_ega_row_update_delegate callback) { downcast<crtc_ega_device &>(device).m_row_update_cb = callback; }
73   static void set_end_update_callback(device_t &device, crtc_ega_end_update_delegate callback) { downcast<crtc_ega_device &>(device).m_end_update_cb = callback; }
74   static void set_hpixels_per_column(device_t &device, int hpixels_per_column) { downcast<crtc_ega_device &>(device).m_hpixels_per_column = hpixels_per_column; }
75   
7876   /* select one of the registers for reading or writing */
7977   DECLARE_WRITE8_MEMBER( address_w );
8078
r29504r29505
106104
107105protected:
108106   // device-level overrides
109   virtual void device_config_complete();
110107   virtual void device_start();
111108   virtual void device_reset();
112109   virtual void device_post_load();
113110   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
114111
115112private:
116   devcb_resolved_write_line   m_res_out_de_func;
117   devcb_resolved_write_line   m_res_out_cur_func;
118   devcb_resolved_write_line   m_res_out_hsync_func;
119   devcb_resolved_write_line   m_res_out_vsync_func;
120   devcb_resolved_write_line   m_res_out_vblank_func;
113   devcb2_write_line   m_res_out_de_cb;
114   devcb2_write_line   m_res_out_hsync_cb;
115   devcb2_write_line   m_res_out_vsync_cb;
116   devcb2_write_line   m_res_out_vblank_cb;
121117
118   /* if specified, this gets called before any pixel update,
119    optionally return a pointer that will be passed to the
120    update and tear down callbacks */
121   crtc_ega_begin_update_delegate      m_begin_update_cb;
122   
123   /* this gets called for every row, the driver must output
124    x_count * hpixels_per_column pixels.
125    cursor_x indicates the character position where the cursor is, or -1
126    if there is no cursor on this row */
127   crtc_ega_row_update_delegate        m_row_update_cb;
128   
129   /* if specified, this gets called after all row updating is complete */
130   crtc_ega_end_update_delegate        m_end_update_cb;
131   
122132   /* ega/vga register file */
123133   UINT8   m_horiz_char_total; /* 0x00 */
124134   UINT8   m_horiz_disp;           /* 0x01 */
r29504r29505
157167   UINT8   m_register_address_latch;
158168   bool    m_cursor_state; /* 0 = off, 1 = on */
159169   UINT8   m_cursor_blink_count;
170   int     m_hpixels_per_column;       /* number of pixels per video memory address */
160171
161172   /* output signals */
162173   int     m_cur;
trunk/src/emu/bus/isa/ega.c
r29504r29505
449449#define EGA_SCREEN_NAME "ega_screen"
450450#define EGA_CRTC_NAME   "crtc_ega_ega"
451451
452
453#define EGA_MODE_GRAPHICS 1
454#define EGA_MODE_TEXT     2
455
456
452457/*
453458    Prototypes
454459*/
455static CRTC_EGA_UPDATE_ROW( ega_update_row );
456460
457static CRTC_EGA_INTERFACE( crtc_ega_ega_intf )
458{
459   8,                  /* numbers of pixels per video memory address */
460   NULL,               /* begin_update */
461   ega_update_row,     /* update_row */
462   NULL,               /* end_update */
463   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, de_changed),       /* on_de_chaged */
464   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, hsync_changed),    /* on_hsync_changed */
465   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, vsync_changed),    /* on vsync_changed */
466   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, isa8_ega_device, vblank_changed)    /* on_vblank_changed */
467};
468
469
470461MACHINE_CONFIG_FRAGMENT( pcvideo_ega )
471462   MCFG_SCREEN_ADD(EGA_SCREEN_NAME, RASTER)
472463   MCFG_SCREEN_RAW_PARAMS(16257000,912,0,640,262,0,200)
r29504r29505
474465   MCFG_SCREEN_PALETTE("palette")
475466
476467   MCFG_PALETTE_ADD( "palette", 64 )
477   MCFG_CRTC_EGA_ADD(EGA_CRTC_NAME, 16257000/8, crtc_ega_ega_intf)
468
469   MCFG_DEVICE_ADD(EGA_CRTC_NAME, CRTC_EGA, 16257000/8)
478470   MCFG_CRTC_EGA_SET_SCREEN(EGA_SCREEN_NAME)
471   MCFG_CRTC_EGA_HPIXELS_PER_COLUMN(8)
472   MCFG_CRTC_EGA_ROW_UPDATE_CB(isa8_ega_device, ega_update_row)
473   MCFG_CRTC_EGA_RES_OUT_DE_CB(WRITELINE(isa8_ega_device, de_changed))
474   MCFG_CRTC_EGA_RES_OUT_HSYNC_CB(WRITELINE(isa8_ega_device, hsync_changed))
475   MCFG_CRTC_EGA_RES_OUT_VSYNC_CB(WRITELINE(isa8_ega_device, vsync_changed))
476   MCFG_CRTC_EGA_RES_OUT_VBLANK_CB(WRITELINE(isa8_ega_device, vblank_changed))
479477MACHINE_CONFIG_END
480478
481479ROM_START( ega )
r29504r29505
664662
665663   install_banks();
666664
667   m_update_row = NULL;
668665   m_misc_output = 0;
669666   m_attribute.index_write = 1;
670667
r29504r29505
686683   m_attribute.data[14] = 0x3E;
687684   m_attribute.data[15] = 0x3F;
688685
686   m_video_mode = 0;
689687}
690688
691689void isa8_ega_device::install_banks()
r29504r29505
746744   }
747745}
748746
749static CRTC_EGA_UPDATE_ROW( ega_update_row )
747CRTC_EGA_ROW_UPDATE( isa8_ega_device::ega_update_row )
750748{
751   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner());
752   if ( ega->m_update_row )
753   {
754      ega->m_update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
755   }
749   if (m_video_mode == EGA_MODE_GRAPHICS)
750      pc_ega_graphics(bitmap, cliprect, ma, ra, y, x_count, cursor_x);
751   else if (m_video_mode == EGA_MODE_TEXT)
752      pc_ega_text(bitmap, cliprect, ma, ra, y, x_count, cursor_x);
756753}
757754
758755
r29504r29505
784781}
785782
786783
787static CRTC_EGA_UPDATE_ROW( pc_ega_graphics )
784CRTC_EGA_ROW_UPDATE( isa8_ega_device::pc_ega_graphics )
788785{
789   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner());
790786   UINT16  *p = &bitmap.pix16(y);
791787
792788//  logerror( "pc_ega_graphics: y = %d, x_count = %d, ma = %d, ra = %d\n", y, x_count, ma, ra );
793789
794   if ( ega->m_graphics_controller.data[5] & 0x10 )
790   if ( m_graphics_controller.data[5] & 0x10 )
795791   {
796792      // Odd/Even mode (CGA compatible)
797793
798794      for ( int i = 0; i < x_count; i++ )
799795      {
800796         UINT16 offset = ( ( ma + i ) & 0x1fff ) | ( ( y & 1 ) << 12 );
801         UINT8 data = ega->m_plane[0][offset];
797         UINT8 data = m_plane[0][offset];
802798
803         *p = ega->m_attribute.data[ ( data >> 6 )        ]; p++;
804         *p = ega->m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++;
805         *p = ega->m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++;
806         *p = ega->m_attribute.data[   data        & 0x03 ]; p++;
799         *p = m_attribute.data[ ( data >> 6 )        ]; p++;
800         *p = m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++;
801         *p = m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++;
802         *p = m_attribute.data[   data        & 0x03 ]; p++;
807803
808         data = ega->m_plane[1][offset];
804         data = m_plane[1][offset];
809805
810         *p = ega->m_attribute.data[ ( data >> 6 )        ]; p++;
811         *p = ega->m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++;
812         *p = ega->m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++;
813         *p = ega->m_attribute.data[   data        & 0x03 ]; p++;
806         *p = m_attribute.data[ ( data >> 6 )        ]; p++;
807         *p = m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++;
808         *p = m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++;
809         *p = m_attribute.data[   data        & 0x03 ]; p++;
814810      }
815811   }
816812   else
817813   {
818814      // EGA mode
819815
820      UINT8 mask = ega->m_attribute.data[0x12] & 0x0f;
816      UINT8 mask = m_attribute.data[0x12] & 0x0f;
821817
822818      for ( int i = 0; i < x_count; i++ )
823819      {
824820         UINT16 offset = ma + i;
825         UINT16 data0 = ega->m_plane[0][offset];
826         UINT16 data1 = ega->m_plane[1][offset] << 1;
827         UINT16 data2 = ega->m_plane[2][offset] << 2;
828         UINT16 data3 = ega->m_plane[3][offset] << 3;
821         UINT16 data0 = m_plane[0][offset];
822         UINT16 data1 = m_plane[1][offset] << 1;
823         UINT16 data2 = m_plane[2][offset] << 2;
824         UINT16 data3 = m_plane[3][offset] << 3;
829825
830826         for ( int j = 7; j >= 0; j-- )
831827         {
r29504r29505
833829
834830            col &= mask;
835831
836            p[j] = ega->m_attribute.data[col];
832            p[j] = m_attribute.data[col];
837833
838834            data0 >>= 1;
839835            data1 >>= 1;
r29504r29505
846842}
847843
848844
849static CRTC_EGA_UPDATE_ROW( pc_ega_text )
845CRTC_EGA_ROW_UPDATE( isa8_ega_device::pc_ega_text )
850846{
851   isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner());
852847   UINT16  *p = &bitmap.pix16(y);
853848   int i;
854849
r29504r29505
857852   for ( i = 0; i < x_count; i++ )
858853   {
859854      UINT16  offset = ma + i;
860      UINT8   chr = ega->m_plane[0][ offset ];
861      UINT8   attr = ega->m_plane[1][ offset ];
855      UINT8   chr = m_plane[0][ offset ];
856      UINT8   attr = m_plane[1][ offset ];
862857      UINT8   data = 0;
863      UINT16  fg = ega->m_attribute.data[ attr & 0x07 ];
864      UINT16  bg = ega->m_attribute.data[ ( attr >> 4 ) & 0x07 ];
858      UINT16  fg = m_attribute.data[ attr & 0x07 ];
859      UINT16  bg = m_attribute.data[ ( attr >> 4 ) & 0x07 ];
865860
866861      /* If character set A and B are equal attribute bit 3 is used as intensity */
867      if ( ega->m_charA == ega->m_charB )
862      if ( m_charA == m_charB )
868863      {
869864         /* intensity selector */
870         data = ega->m_charB[ chr * 32 + ra ];
865         data = m_charB[ chr * 32 + ra ];
871866         fg += ( attr & 0x08 ) ? 0x38 : 0x00;
872867      }
873868      else
874869      {
875870         /* character set selector */
876         data = ( attr & 0x08 ) ? ega->m_charA[ chr * 32 + ra ] : ega->m_charB[ chr * 32 + ra ];
871         data = ( attr & 0x08 ) ? m_charA[ chr * 32 + ra ] : m_charB[ chr * 32 + ra ];
877872      }
878873
879874      if ( i == cursor_x )
880875      {
881         if ( ega->m_frame_cnt & 0x08 )
876         if ( m_frame_cnt & 0x08 )
882877         {
883878            data = 0xFF;
884879         }
r29504r29505
886881      else
887882      {
888883         /* Check for blinking */
889         if ( ( ega->m_attribute.data[0x10] & 0x08 ) && ( attr & 0x80 ) && ( ega->m_frame_cnt & 0x10 ) )
884         if ( ( m_attribute.data[0x10] & 0x08 ) && ( attr & 0x80 ) && ( m_frame_cnt & 0x10 ) )
890885         {
891886            data = 0x00;
892887         }
r29504r29505
908903{
909904   int clock, pixels;
910905
911   m_update_row = NULL;
906   m_video_mode = 0;
912907
913908   /* Check for graphics mode */
914909   if (   ( m_attribute.data[0x10] & 0x01 ) &&
r29504r29505
920915         logerror("change_mode(): Switch to graphics mode\n");
921916      }
922917
923      m_update_row = pc_ega_graphics;
918      m_video_mode = EGA_MODE_GRAPHICS;
924919   }
925920
926921   /* Check for text mode */
r29504r29505
933928         logerror("chnage_mode(): Switching to text mode\n");
934929      }
935930
936      m_update_row = pc_ega_text;
931      m_video_mode = EGA_MODE_TEXT;
937932
938933      /* Set character maps */
939934      if ( m_sequencer.data[0x04] & 0x02 )
r29504r29505
959954   m_crtc_ega->set_clock( clock / pixels );
960955   m_crtc_ega->set_hpixels_per_column( pixels );
961956
962if ( ! m_update_row )
963   logerror("unknown video mode\n");
957   if (!m_video_mode)
958      logerror("unknown video mode\n");
964959}
965960
966961
trunk/src/emu/bus/isa/ega.h
r29504r29505
4040      DECLARE_WRITE_LINE_MEMBER(vsync_changed);
4141      DECLARE_WRITE_LINE_MEMBER(vblank_changed);
4242
43      CRTC_EGA_ROW_UPDATE(ega_update_row);
44      CRTC_EGA_ROW_UPDATE(pc_ega_graphics);
45      CRTC_EGA_ROW_UPDATE(pc_ega_text);
46
4347protected:
4448      // device-level overrides
4549      virtual void device_start();
r29504r29505
5559      DECLARE_WRITE8_MEMBER(pc_ega8_3X0_w);
5660      DECLARE_READ8_MEMBER(pc_ega8_3X0_r);
5761
58      crtc_ega_update_row_func    m_update_row;
59
6062      /* Video memory and related variables */
6163      memory_region   *m_vram;
6264      UINT8   *m_plane[4];
r29504r29505
9698      UINT8   m_vsync;
9799      UINT8   m_vblank;
98100      UINT8   m_display_enable;
101      int     m_video_mode;
99102      required_device<palette_device> m_palette;
100103};
101104

Previous 199869 Revisions Next


© 1997-2024 The MAME Team