Previous 15994 Revisions Next

r14391 Wednesday 8th February, 2012 at 20:18:43 UTC by Wilbert Pol
isa_mda.c: Refactored the code a little bit, also added pixel stream implementation for the hercules card. (nw)
[src/mess/video]isa_mda.c isa_mda.h

src/mess/video/isa_mda.c
r14390r14391
174174void isa8_mda_device::device_start()
175175{
176176   set_isa_device();
177   videoram = auto_alloc_array(machine(), UINT8, 0x1000);
177   m_videoram = auto_alloc_array(machine(), UINT8, 0x1000);
178178   m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate( FUNC(isa8_mda_device::io_read), this ), write8_delegate( FUNC(isa8_mda_device::io_write), this ) );
179   m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", videoram);
179   m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", m_videoram);
180180
181181   /* Initialise the mda palette */
182182   for(int i = 0; i < (sizeof(mda_palette) / 3); i++)
r14390r14391
189189
190190void isa8_mda_device::device_reset()
191191{
192   update_row = NULL;
193   framecnt = 0;
194   mode_control = 0;
195   vsync = 0;
196   hsync = 0;
192   m_update_row = NULL;
193   m_framecnt = 0;
194   m_mode_control = 0;
195   m_vsync = 0;
196   m_hsync = 0;
197197   m_pixel = 0;
198198
199199   astring tempstring;
200   chr_gen = machine().region(subtag(tempstring, "gfx1"))->base();
200   m_chr_gen = machine().region(subtag(tempstring, "gfx1"))->base();
201201}
202202
203203/***************************************************************************
r14390r14391
224224   for ( i = 0; i < x_count; i++ )
225225   {
226226      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
227      UINT8 chr = mda->videoram[ offset ];
228      UINT8 attr = mda->videoram[ offset + 1 ];
229      UINT8 data = mda->chr_gen[ chr_base + chr * 8 ];
227      UINT8 chr = mda->m_videoram[ offset ];
228      UINT8 attr = mda->m_videoram[ offset + 1 ];
229      UINT8 data = mda->m_chr_gen[ chr_base + chr * 8 ];
230230      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
231231      UINT8 bg = 0;
232232
r14390r14391
255255         break;
256256      }
257257
258      if ( ( i == cursor_x && ( mda->framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 )
258      if ( ( i == cursor_x && ( mda->m_framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 )
259259      {
260260         data = 0xFF;
261261      }
r14390r14391
298298   for ( i = 0; i < x_count; i++ )
299299   {
300300      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
301      UINT8 chr = mda->videoram[ offset ];
302      UINT8 attr = mda->videoram[ offset + 1 ];
303      UINT8 data = mda->chr_gen[ chr_base + chr * 8 ];
301      UINT8 chr = mda->m_videoram[ offset ];
302      UINT8 attr = mda->m_videoram[ offset + 1 ];
303      UINT8 data = mda->m_chr_gen[ chr_base + chr * 8 ];
304304      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
305305      UINT8 bg = 0;
306306
r14390r14391
330330
331331      if ( i == cursor_x )
332332      {
333         if ( mda->framecnt & 0x08 )
333         if ( mda->m_framecnt & 0x08 )
334334         {
335335            data = 0xFF;
336336         }
337337      }
338338      else
339339      {
340         if ( ( attr & 0x80 ) && ( mda->framecnt & 0x10 ) )
340         if ( ( attr & 0x80 ) && ( mda->m_framecnt & 0x10 ) )
341341         {
342342            data = 0x00;
343343         }
r14390r14391
366366static MC6845_UPDATE_ROW( mda_update_row )
367367{
368368   isa8_mda_device   *mda  = downcast<isa8_mda_device *>(device->owner());
369   if ( mda->update_row )
369   if ( mda->m_update_row )
370370   {
371      mda->update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
371      mda->m_update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
372372   }
373373}
374374
375375
376376WRITE_LINE_MEMBER( isa8_mda_device::hsync_changed )
377377{
378   hsync = state ? 1 : 0;
378   m_hsync = state ? 1 : 0;
379379}
380380
381381
382382WRITE_LINE_MEMBER( isa8_mda_device::vsync_changed )
383383{
384   vsync = state ? 0x80 : 0;
384   m_vsync = state ? 0x80 : 0;
385385   if ( state )
386386   {
387      framecnt++;
387      m_framecnt++;
388388   }
389389}
390390
r14390r14391
394394 */
395395WRITE8_MEMBER( isa8_mda_device::mode_control_w )
396396{
397   mode_control = data;
397   m_mode_control = data;
398398
399   switch( mode_control & 0x2a )
399   switch( m_mode_control & 0x2a )
400400   {
401401   case 0x08:
402      update_row = mda_text_inten_update_row;
402      m_update_row = mda_text_inten_update_row;
403403      break;
404404   case 0x28:
405      update_row = mda_text_blink_update_row;
405      m_update_row = mda_text_blink_update_row;
406406      break;
407407   default:
408      update_row = NULL;
408      m_update_row = NULL;
409409   }
410410}
411411
r14390r14391
426426   // Faking pixel stream here
427427   m_pixel++;
428428
429   return 0xF0 | (m_pixel & 0x08) | hsync;
429   return 0xF0 | (m_pixel & 0x08) | m_hsync;
430430}
431431
432432
r14390r14391
581581
582582void isa8_hercules_device::device_start()
583583{
584   videoram = auto_alloc_array(machine(), UINT8, 0x10000);
584   m_videoram = auto_alloc_array(machine(), UINT8, 0x10000);
585585   set_isa_device();
586586   m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, FUNC(hercules_r), FUNC(hercules_w) );
587   m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", videoram);
587   m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", m_videoram);
588588
589589   /* Initialise the mda palette */
590590   for(int i = 0; i < (sizeof(mda_palette) / 3); i++)
r14390r14391
598598void isa8_hercules_device::device_reset()
599599{
600600   isa8_mda_device::device_reset();
601   configuration_switch = 0;
601   m_configuration_switch = 0;
602602
603603   astring tempstring;
604   chr_gen = machine().region(subtag(tempstring, "gfx1"))->base();
604   m_chr_gen = machine().region(subtag(tempstring, "gfx1"))->base();
605605}
606606
607607/***************************************************************************
r14390r14391
616616   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device->owner());
617617   const rgb_t *palette = palette_entry_list_raw(bitmap.palette());
618618   UINT32   *p = &bitmap.pix32(y);
619   UINT16   gfx_base = ( ( herc->mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 );
619   UINT16   gfx_base = ( ( herc->m_mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 );
620620   int i;
621621   if ( y == 0 ) MDA_LOG(1,"hercules_gfx_update_row",("\n"));
622622   for ( i = 0; i < x_count; i++ )
623623   {
624      UINT8   data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) ];
624      UINT8   data = herc->m_videoram[ gfx_base + ( ( ma + i ) << 1 ) ];
625625
626626      *p = palette[( data & 0x80 ) ? 2 : 0]; p++;
627627      *p = palette[( data & 0x40 ) ? 2 : 0]; p++;
r14390r14391
632632      *p = palette[( data & 0x02 ) ? 2 : 0]; p++;
633633      *p = palette[( data & 0x01 ) ? 2 : 0]; p++;
634634
635      data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ];
635      data = herc->m_videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ];
636636
637637      *p = palette[( data & 0x80 ) ? 2 : 0]; p++;
638638      *p = palette[( data & 0x40 ) ? 2 : 0]; p++;
r14390r14391
652652
653653   MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
654654      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
655   herc->mode_control = data;
655   herc->m_mode_control = data;
656656
657   switch( herc->mode_control & 0x2a )
657   switch( herc->m_mode_control & 0x2a )
658658   {
659659   case 0x08:
660      herc->update_row = mda_text_inten_update_row;
660      herc->m_update_row = mda_text_inten_update_row;
661661      break;
662662   case 0x28:
663      herc->update_row = mda_text_blink_update_row;
663      herc->m_update_row = mda_text_blink_update_row;
664664      break;
665665   case 0x0A:          /* Hercules modes */
666666   case 0x2A:
667      herc->update_row = hercules_gfx_update_row;
667      herc->m_update_row = hercules_gfx_update_row;
668668      break;
669669   default:
670      herc->update_row = NULL;
670      herc->m_update_row = NULL;
671671   }
672672
673   downcast<mc6845_device *>(device)->set_clock( herc->mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 );
674   downcast<mc6845_device *>(device)->set_hpixels_per_column( herc->mode_control & 0x02 ? 16 : 9 );
673   downcast<mc6845_device *>(device)->set_clock( herc->m_mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 );
674   downcast<mc6845_device *>(device)->set_hpixels_per_column( herc->m_mode_control & 0x02 ? 16 : 9 );
675675}
676676
677677
r14390r14391
679679{
680680   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device);
681681   MDA_LOG(1,"HGC_config_w",("$%02x\n", data));
682   herc->configuration_switch = data;
682   herc->m_configuration_switch = data;
683683}
684684
685685
r14390r14391
723723static READ8_DEVICE_HANDLER(hercules_status_r)
724724{
725725   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device);
726   return herc->vsync | 0x08 | herc->hsync;
726
727   // Faking pixel stream here
728   herc->m_pixel++;
729
730   return herc->m_vsync | ( herc->m_pixel & 0x08 ) | herc->m_hsync;
727731}
728732
729733
src/mess/video/isa_mda.h
r14390r14391
4040        virtual void device_start();
4141        virtual void device_reset();
4242public:
43      int  framecnt;
43      int   m_framecnt;
4444
45      UINT8 mode_control;
45      UINT8   m_mode_control;
4646
47      mc6845_update_row_func  update_row;
48      UINT8   *chr_gen;
49      UINT8   vsync;
50      UINT8   hsync;
51      UINT8  *videoram;
47      mc6845_update_row_func  m_update_row;
48      UINT8   *m_chr_gen;
49      UINT8   m_vsync;
50      UINT8   m_hsync;
51      UINT8   *m_videoram;
5252      UINT8   m_pixel;
5353};
5454
r14390r14391
7676private:
7777        // internal state
7878public:
79      UINT8 configuration_switch; //hercules
79      UINT8 m_configuration_switch; //hercules
8080};
8181
8282

Previous 15994 Revisions Next


© 1998-2018 The MESS Team