Previous 15994 Revisions Next

r14393 Wednesday 8th February, 2012 at 20:56:27 UTC by Wilbert Pol
isa_mda.c: Refactored the hercules code a bit to use some more c++ features. (nw)
[src/mess/video]isa_mda.c isa_mda.h

src/mess/video/isa_mda.c
r14392r14393
488488
489489***************************************************************************/
490490
491static READ8_DEVICE_HANDLER( hercules_r );
492static WRITE8_DEVICE_HANDLER( hercules_w );
493
494491/*
495492When the Hercules changes to graphics mode, the number of pixels per access and
496493clock divider should be changed. The currect mc6845 implementation does not
r14392r14393
583580{
584581   m_videoram = auto_alloc_array(machine(), UINT8, 0x10000);
585582   set_isa_device();
586   m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, FUNC(hercules_r), FUNC(hercules_w) );
583   m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate( FUNC(isa8_hercules_device::io_read), this ), write8_delegate( FUNC(isa8_hercules_device::io_write), this ) );
587584   m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", m_videoram);
588585
589586   /* Initialise the mda palette */
r14392r14393
646643}
647644
648645
649static WRITE8_DEVICE_HANDLER(hercules_mode_control_w)
646WRITE8_MEMBER( isa8_hercules_device::mode_control_w )
650647{
651   isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner());
648   mc6845_device *mc6845 = subdevice<mc6845_device>(HERCULES_MC6845_NAME);
652649
653   MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
654      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
655   herc->m_mode_control = data;
650   m_mode_control = data;
656651
657   switch( herc->m_mode_control & 0x2a )
652   switch( m_mode_control & 0x2a )
658653   {
659654   case 0x08:
660      herc->m_update_row = mda_text_inten_update_row;
655      m_update_row = mda_text_inten_update_row;
661656      break;
662657   case 0x28:
663      herc->m_update_row = mda_text_blink_update_row;
658      m_update_row = mda_text_blink_update_row;
664659      break;
665660   case 0x0A:          /* Hercules modes */
666661   case 0x2A:
667      herc->m_update_row = hercules_gfx_update_row;
662      m_update_row = hercules_gfx_update_row;
668663      break;
669664   default:
670      herc->m_update_row = NULL;
665      m_update_row = NULL;
671666   }
672667
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 );
668   mc6845->set_clock( m_mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 );
669   mc6845->set_hpixels_per_column( m_mode_control & 0x02 ? 16 : 9 );
675670}
676671
677672
678static WRITE8_DEVICE_HANDLER(hercules_config_w)
673WRITE8_MEMBER( isa8_hercules_device::io_write )
679674{
680   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device);
681   MDA_LOG(1,"HGC_config_w",("$%02x\n", data));
682   herc->m_configuration_switch = data;
683}
684
685
686static WRITE8_DEVICE_HANDLER ( hercules_w )
687{
688   mc6845_device *mc6845 = downcast<mc6845_device *>(device->subdevice(HERCULES_MC6845_NAME));
689   address_space *space = device->machine().device("maincpu")->memory().space(AS_PROGRAM);
690   device_t *lpt = device->subdevice("lpt");
675   mc6845_device *mc6845 = subdevice<mc6845_device>(HERCULES_MC6845_NAME);
676   device_t *lpt = subdevice("lpt");
691677   switch( offset )
692678   {
693679   case 0: case 2: case 4: case 6:
694      mc6845->address_w( *space, offset, data );
680      mc6845->address_w( space, offset, data );
695681      break;
696682   case 1: case 3: case 5: case 7:
697      mc6845->register_w( *space, offset, data );
683      mc6845->register_w( space, offset, data );
698684      break;
699685   case 8:
700      hercules_mode_control_w(mc6845, offset, data);
686      mode_control_w(space, offset, data);
701687      break;
702688   case 12: case 13:  case 14:
703689      pc_lpt_w(lpt, offset - 12, data);
704690      break;
705691   case 15:
706      hercules_config_w(device, offset, data);
692      m_configuration_switch = data;
707693      break;
708694   }
709695}
r14392r14393
720706 *      2-1  reserved
721707 *      0    horizontal drive enable
722708 */
723static READ8_DEVICE_HANDLER(hercules_status_r)
709READ8_MEMBER( isa8_hercules_device::status_r )
724710{
725   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device);
726
727711   // Faking pixel stream here
728   herc->m_pixel++;
712   m_pixel++;
729713
730   return herc->m_vsync | ( herc->m_pixel & 0x08 ) | herc->m_hsync;
714   return m_vsync | ( m_pixel & 0x08 ) | m_hsync;
731715}
732716
733717
734static READ8_DEVICE_HANDLER ( hercules_r )
718READ8_MEMBER( isa8_hercules_device::io_read )
735719{
736720   int data = 0xff;
737   mc6845_device *mc6845 = downcast<mc6845_device *>(device->subdevice(HERCULES_MC6845_NAME));
738   address_space *space = device->machine().device("maincpu")->memory().space(AS_PROGRAM);
739   device_t *lpt = device->subdevice("lpt");
721   mc6845_device *mc6845 = subdevice<mc6845_device>(HERCULES_MC6845_NAME);
722   device_t *lpt = subdevice("lpt");
740723   switch( offset )
741724   {
742725   case 0: case 2: case 4: case 6:
743726      /* return last written mc6845 address value here? */
744727      break;
745728   case 1: case 3: case 5: case 7:
746      data = mc6845->register_r( *space, offset );
729      data = mc6845->register_r( space, offset );
747730      break;
748731   case 10:
749      data = hercules_status_r(device, offset);
732      data = status_r(space, offset);
750733      break;
751734   /* 12, 13, 14  are the LPT ports */
752735   case 12: case 13:  case 14:
src/mess/video/isa_mda.h
r14392r14393
3030
3131      DECLARE_WRITE_LINE_MEMBER(hsync_changed);
3232      DECLARE_WRITE_LINE_MEMBER(vsync_changed);
33      DECLARE_READ8_MEMBER(io_read);
34      DECLARE_WRITE8_MEMBER(io_write);
35      DECLARE_READ8_MEMBER(status_r);
36      DECLARE_WRITE8_MEMBER(mode_control_w);
33      virtual DECLARE_READ8_MEMBER(io_read);
34      virtual DECLARE_WRITE8_MEMBER(io_write);
35      virtual DECLARE_READ8_MEMBER(status_r);
36      virtual DECLARE_WRITE8_MEMBER(mode_control_w);
3737
3838protected:
3939        // device-level overrides
r14392r14393
6868      virtual machine_config_constructor device_mconfig_additions() const;
6969      virtual const rom_entry *device_rom_region() const;
7070
71      virtual DECLARE_READ8_MEMBER(io_read);
72      virtual DECLARE_WRITE8_MEMBER(io_write);
73      virtual DECLARE_READ8_MEMBER(status_r);
74      virtual DECLARE_WRITE8_MEMBER(mode_control_w);
75
7176protected:
7277        // device-level overrides
7378        virtual void device_start();

Previous 15994 Revisions Next


© 1998-2018 The MESS Team