Previous 15994 Revisions Next

r10667 Friday 4th March, 2011 at 11:18:11 UTC by Miodrag Milanović
- Added ISA bus device and ISA card interface
- Converted MDA and Hercules to be ISA cards
- Updated generic PC drivers to use this
[src/mess]mess.mak
[src/mess/drivers]pc.c
[src/mess/machine]isa.c* isa.h*
[src/mess/video]pc_mda.c pc_mda.h

src/mess/machine/isa.c
r0r10667
1/***************************************************************************
2 
3        ISA bus device
4 
5***************************************************************************/
6 
7#include "emu.h"
8#include "machine/isa.h"
9 
10 
11//**************************************************************************
12//  GLOBAL VARIABLES
13//**************************************************************************
14 
15const device_type ISA8 = isa8_device_config::static_alloc_device_config;
16 
17//**************************************************************************
18//  DEVICE CONFIGURATION
19//**************************************************************************
20 
21//-------------------------------------------------
22//  isa8_device_config - constructor
23//-------------------------------------------------
24 
25isa8_device_config::isa8_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
26        : device_config(mconfig, static_alloc_device_config, "ISA8", tag, owner, clock)
27{
28}
29 
30//-------------------------------------------------
31//  static_alloc_device_config - allocate a new
32//  configuration object
33//-------------------------------------------------
34 
35device_config *isa8_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
36{
37        return global_alloc(isa8_device_config(mconfig, tag, owner, clock));
38}
39 
40//-------------------------------------------------
41//  alloc_device - allocate a new device object
42//-------------------------------------------------
43 
44device_t *isa8_device_config::alloc_device(running_machine &machine) const
45{
46        return auto_alloc(&machine, isa8_device(machine, *this));
47}
48 
49void isa8_device_config::static_set_cputag(device_config *device, const char *tag)
50{
51        isa8_device_config *isa = downcast<isa8_device_config *>(device);
52        isa->m_cputag = tag;
53}
54 
55//**************************************************************************
56//  LIVE DEVICE
57//**************************************************************************
58 
59//-------------------------------------------------
60//  isa8_device - constructor
61//-------------------------------------------------
62 
63isa8_device::isa8_device(running_machine &_machine, const isa8_device_config &config) :
64        device_t(_machine, config),
65        m_config(config)
66{
67}
68 
69//-------------------------------------------------
70//  device_start - device-specific startup
71//-------------------------------------------------
72 
73void isa8_device::device_start()
74{       
75        device_t *cpu = m_machine.device(m_config.m_cputag);
76        m_space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM);
77}
78 
79//-------------------------------------------------
80//  device_reset - device-specific reset
81//-------------------------------------------------
82 
83void isa8_device::device_reset()
84{
85}
86
87
88//**************************************************************************
89//  DEVICE CONFIG ISA8 CARD INTERFACE
90//**************************************************************************
91
92//-------------------------------------------------
93//  device_config_isa8_card_interface - constructor
94//-------------------------------------------------
95
96device_config_isa8_card_interface::device_config_isa8_card_interface(const machine_config &mconfig, device_config &devconfig)
97   : device_config_interface(mconfig, devconfig)   
98{
99}
100
101
102//-------------------------------------------------
103//  ~device_config_isa8_card_interface - destructor
104//-------------------------------------------------
105
106device_config_isa8_card_interface::~device_config_isa8_card_interface()
107{
108}
109
110void device_config_isa8_card_interface::static_set_isa8_tag(device_config *device, const char *tag)
111{
112   device_config_isa8_card_interface *isa_card = dynamic_cast<device_config_isa8_card_interface *>(device);
113   isa_card->m_isa_tag = tag;
114}
115
116void device_config_isa8_card_interface::static_set_isa8_num(device_config *device, int num)
117{
118   device_config_isa8_card_interface *isa_card = dynamic_cast<device_config_isa8_card_interface *>(device);
119   isa_card->m_isa_num = num;
120}
121
122
123//**************************************************************************
124//  DEVICE ISA8 CARD INTERFACE
125//**************************************************************************
126
127//-------------------------------------------------
128//  device_isa8_card_interface - constructor
129//-------------------------------------------------
130
131device_isa8_card_interface::device_isa8_card_interface(running_machine &machine, const device_config &config, device_t &device)
132   : device_interface(machine, config, device),
133     m_isa8_card_config(dynamic_cast<const device_config_isa8_card_interface &>(config))
134{
135}
136
137
138//-------------------------------------------------
139//  ~device_isa8_card_interface - destructor
140//-------------------------------------------------
141
142device_isa8_card_interface::~device_isa8_card_interface()
143{
144}
src/mess/machine/isa.h
r0r10667
1/***************************************************************************
2 
3        ISA bus device
4 
5***************************************************************************/
6 
7#pragma once
8 
9#ifndef __ISA_H__
10#define __ISA_H__
11 
12#include "emu.h"
13 
14 
15//**************************************************************************
16//  INTERFACE CONFIGURATION MACROS
17//**************************************************************************
18 
19#define MCFG_ISA8_BUS_ADD(_tag, _cputag) \
20    MCFG_DEVICE_ADD(_tag, ISA8, 0) \
21    isa8_device_config::static_set_cputag(device, _cputag); \
22 
23#define MCFG_ISA8_BUS_DEVICE(_isatag, _num, _tag, _dev_type) \
24    MCFG_DEVICE_ADD(_tag, _dev_type, 0) \
25   device_config_isa8_card_interface::static_set_isa8_tag(device, _isatag); \
26   device_config_isa8_card_interface::static_set_isa8_num(device, _num); \
27
28   
29//**************************************************************************
30//  TYPE DEFINITIONS
31//**************************************************************************
32 
33// ======================> isa8_device_config
34 
35class isa8_device_config : public device_config
36{
37        friend class isa8_device;
38 
39        // construction/destruction
40        isa8_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
41 
42public:
43        // allocators
44        static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
45        virtual device_t *alloc_device(running_machine &machine) const;
46 
47        // inline configuration
48        static void static_set_cputag(device_config *device, const char *tag);
49 
50        const char *m_cputag;
51};
52 
53 
54// ======================> isa8_device
55 
56class isa8_device : public device_t
57{
58        friend class isa8_device_config;
59 
60        // construction/destruction
61        isa8_device(running_machine &_machine, const isa8_device_config &config);
62
63protected:
64        // device-level overrides
65        virtual void device_start();
66        virtual void device_reset();
67 
68private:
69        // internal state
70        const isa8_device_config &m_config;
71 
72        address_space *m_space;
73};
74 
75 
76// device type definition
77extern const device_type ISA8;
78 
79
80// ======================> device_config_isa8_card_interface
81
82// class representing interface-specific configuration isa8 card
83class device_config_isa8_card_interface : public device_config_interface
84{
85public:
86   // construction/destruction
87   device_config_isa8_card_interface(const machine_config &mconfig, device_config &device);
88   virtual ~device_config_isa8_card_interface();
89    // inline configuration
90    static void static_set_isa8_tag(device_config *device, const char *tag);
91    static void static_set_isa8_num(device_config *device, int num);   
92protected:
93   const char *m_isa_tag;
94   int m_isa_num;
95};
96
97
98// ======================> device_isa8_card_interface
99
100// class representing interface-specific live isa8 card
101class device_isa8_card_interface : public device_interface
102{
103public:
104   // construction/destruction
105   device_isa8_card_interface(running_machine &machine, const device_config &config, device_t &device);
106   virtual ~device_isa8_card_interface();
107
108   // configuration access
109   const device_config_isa8_card_interface &isa8_card_config() const { return m_isa8_card_config; }
110
111protected:
112
113   // configuration
114   const device_config_isa8_card_interface &m_isa8_card_config;   // reference to our device_config_execute_interface
115};
116 
117#endif  /* __ISA_H__ */
src/mess/video/pc_mda.c
r10666r10667
88#include "pc_mda.h"
99#include "video/mc6845.h"
1010
11#define MDA_SCREEN_NAME   "mda_screen"
12#define MDA_MC6845_NAME   "mc6845_mda"
13
14/*
15  Hercules video card
16 */
17#define HERCULES_SCREEN_NAME "hercules_screen"
18#define HERCULES_MC6845_NAME "mc6845_hercules"
19
1120#define VERBOSE_MDA   0      /* MDA (Monochrome Display Adapter) */
1221
1322#define MDA_CLOCK   16257000
r10666r10667
1726      if(VERBOSE_MDA>=N) \
1827      { \
1928         if( M ) \
20            logerror("%11.6f: %-24s",machine->time().as_double(),(char*)M ); \
29            logerror("%11.6f: %-24s",device->machine->time().as_double(),(char*)M ); \
2130         logerror A; \
2231      } \
2332   } while (0)
r10666r10667
3039   { 0x00,0xff,0x00 }
3140};
3241
33static struct
34{
35   UINT8 status;
36
37   int pc_framecnt;
38
39   UINT8 mode_control, configuration_switch; //hercules
40
41   mc6845_update_row_func  update_row;
42   UINT8   *chr_gen;
43   UINT8   vsync;
44   UINT8   hsync;
45   UINT8  *videoram;
46} mda;
47
48/* Initialise the mda palette */
49static PALETTE_INIT( pc_mda )
50{
51   int i;
52   for(i = 0; i < (sizeof(mda_palette) / 3); i++)
53      palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]);
54}
55
56static VIDEO_START( pc_mda );
5742static SCREEN_UPDATE( mc6845_mda );
58static READ8_HANDLER( pc_MDA_r );
59static WRITE8_HANDLER( pc_MDA_w );
43static READ8_DEVICE_HANDLER( pc_MDA_r );
44static WRITE8_DEVICE_HANDLER( pc_MDA_w );
6045static MC6845_UPDATE_ROW( mda_update_row );
6146static WRITE_LINE_DEVICE_HANDLER( mda_hsync_changed );
6247static WRITE_LINE_DEVICE_HANDLER( mda_vsync_changed );
6348
49/* F4 Character Displayer */
50static const gfx_layout pc_16_charlayout =
51{
52   8, 16,               /* 8 x 16 characters */
53   256,               /* 256 characters */
54   1,               /* 1 bits per pixel */
55   { 0 },               /* no bitplanes */
56   /* x offsets */
57   { 0, 1, 2, 3, 4, 5, 6, 7 },
58   /* y offsets */
59   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 2048*8, 2049*8, 2050*8, 2051*8, 2052*8, 2053*8, 2054*8, 2055*8 },
60   8*8               /* every char takes 2 x 8 bytes */
61};
62
63static const gfx_layout pc_8_charlayout =
64{
65   8, 8,               /* 8 x 8 characters */
66   512,               /* 512 characters */
67   1,               /* 1 bits per pixel */
68   { 0 },               /* no bitplanes */
69   /* x offsets */
70   { 0, 1, 2, 3, 4, 5, 6, 7 },
71   /* y offsets */
72   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
73   8*8               /* every char takes 8 bytes */
74};
75
76static GFXDECODE_START( pcmda )
77   GFXDECODE_ENTRY( "mda:gfx1", 0x0000, pc_16_charlayout, 1, 1 )
78   GFXDECODE_ENTRY( "mda:gfx1", 0x1000, pc_8_charlayout, 1, 1 )
79GFXDECODE_END
80
6481static const mc6845_interface mc6845_mda_intf =
6582{
66   MDA_SCREEN_NAME,   /* screen number */
83   MDA_SCREEN_NAME, /* screen number */
6784   9,               /* number of pixels per video memory address */
6885   NULL,            /* begin_update */
6986   mda_update_row,      /* update_row */
r10666r10667
8198   MCFG_SCREEN_RAW_PARAMS(MDA_CLOCK, 882, 0, 720, 370, 0, 350 )
8299   MCFG_SCREEN_UPDATE( mc6845_mda)
83100
84   MCFG_PALETTE_LENGTH( sizeof(mda_palette) / 3 )
85   MCFG_PALETTE_INIT(pc_mda)
86
87101   MCFG_MC6845_ADD( MDA_MC6845_NAME, MC6845, MDA_CLOCK/9, mc6845_mda_intf)
88102
89   MCFG_VIDEO_START( pc_mda )
103   MCFG_GFXDECODE(pcmda)
90104MACHINE_CONFIG_END
91105
106ROM_START( mda )
107   /* IBM 1501981(CGA) and 1501985(MDA) Character rom */
108   ROM_REGION(0x08100,"gfx1", 0)
109   ROM_LOAD("5788005.u33", 0x00000, 0x02000, CRC(0bf56d70) SHA1(c2a8b10808bf51a3c123ba3eb1e9dd608231916f)) /* "AMI 8412PI // 5788005 // (C) IBM CORP. 1981 // KOREA" */
110ROM_END
92111
93/***************************************************************************
112//**************************************************************************
113//  GLOBAL VARIABLES
114//**************************************************************************
115 
116const device_type ISA8_MDA = isa8_mda_device_config::static_alloc_device_config;
117 
118//**************************************************************************
119//  DEVICE CONFIGURATION
120//**************************************************************************
121 
122//-------------------------------------------------
123//  isa8_mda_device_config - constructor
124//-------------------------------------------------
125 
126isa8_mda_device_config::isa8_mda_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
127        : device_config(mconfig, static_alloc_device_config, "ISA8_MDA", tag, owner, clock),
128         device_config_isa8_card_interface(mconfig, *this)
129{
130   m_shortname = "mda";
131}
132 
133//-------------------------------------------------
134//  static_alloc_device_config - allocate a new
135//  configuration object
136//-------------------------------------------------
137 
138device_config *isa8_mda_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
139{
140        return global_alloc(isa8_mda_device_config(mconfig, tag, owner, clock));
141}
142 
143//-------------------------------------------------
144//  alloc_device - allocate a new device object
145//-------------------------------------------------
146 
147device_t *isa8_mda_device_config::alloc_device(running_machine &machine) const
148{
149        return auto_alloc(&machine, isa8_mda_device(machine, *this));
150}
151 
152//-------------------------------------------------
153//  machine_config_additions - device-specific
154//  machine configurations
155//-------------------------------------------------
94156
95  Monochrome Display Adapter (MDA) section
157machine_config_constructor isa8_mda_device_config::machine_config_additions() const
158{
159   return MACHINE_CONFIG_NAME( pcvideo_mda );
160}
96161
97***************************************************************************/
162//-------------------------------------------------
163//  rom_region - device-specific ROM region
164//-------------------------------------------------
98165
99VIDEO_START( pc_mda )
166const rom_entry *isa8_mda_device_config::rom_region() const
100167{
168   return ROM_NAME( mda );
169}
170
171//**************************************************************************
172//  LIVE DEVICE
173//**************************************************************************
174 
175//-------------------------------------------------
176//  isa8_mda_device - constructor
177//-------------------------------------------------
178 
179isa8_mda_device::isa8_mda_device(running_machine &_machine, const isa8_mda_device_config &config) :
180        device_t(_machine, config),
181      device_isa8_card_interface( _machine, config, *this ),
182        m_config(config)
183{
184}
185 
186//-------------------------------------------------
187//  device_start - device-specific startup
188//-------------------------------------------------
189 
190void isa8_mda_device::device_start()
191{       
101192   int buswidth;
102193   address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM);
103194
r10666r10667
105196   switch(buswidth)
106197   {
107198      case 8:
108         memory_install_readwrite_bank(space, 0xb0000, 0xb0fff, 0, 0x07000, "bank11" );
109         memory_install_read8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_MDA_r );
110         memory_install_write8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_MDA_w );
199         memory_install_readwrite_bank(space, 0xb0000, 0xb0fff, 0, 0x07000, "bank_mda" );
200         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, pc_MDA_r, pc_MDA_w );
111201         break;
112202
113203      default:
r10666r10667
115205         break;
116206   }
117207
118   memset( &mda, 0, sizeof(mda));
119   mda.update_row = NULL;
120   mda.chr_gen = machine->region( "gfx1" )->base();
208   videoram = auto_alloc_array(machine, UINT8, 0x1000);
209   
210   memory_set_bankptr(machine,"bank_mda", videoram);
121211
122   mda.videoram = auto_alloc_array(machine, UINT8, 0x1000);
123   memory_set_bankptr(machine,"bank11", mda.videoram);
212   /* Initialise the mda palette */
213   for(int i = 0; i < (sizeof(mda_palette) / 3); i++)
214      palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]);   
124215}
216 
217//-------------------------------------------------
218//  device_reset - device-specific reset
219//-------------------------------------------------
220 
221void isa8_mda_device::device_reset()
222{
223   update_row = NULL;
224   framecnt = 0;
225   mode_control = 0;
226   vsync = 0;
227   hsync = 0;
228   
229   astring tempstring;
230   chr_gen = machine->region(subtag(tempstring, "gfx1"))->base();   
231}
125232
233/***************************************************************************
126234
235  Monochrome Display Adapter (MDA) section
236
237***************************************************************************/
238
127239static SCREEN_UPDATE( mc6845_mda )
128240{
129   device_t *devconf = screen->machine->device(MDA_MC6845_NAME);
241   device_t *devconf = screen->owner()->subdevice(MDA_MC6845_NAME);
130242   mc6845_update( devconf, bitmap, cliprect );
131243   return 0;
132244}
r10666r10667
140252
141253static MC6845_UPDATE_ROW( mda_text_inten_update_row )
142254{
143   UINT8 *videoram = mda.videoram;
255   isa8_mda_device   *mda = downcast<isa8_mda_device *>(device->owner());
144256   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
145257   UINT16   chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra;
146258   int i;
147   running_machine *machine = device->machine;
148259
149260   if ( y == 0 ) MDA_LOG(1,"mda_text_inten_update_row",("\n"));
150261   for ( i = 0; i < x_count; i++ )
151262   {
152263      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
153      UINT8 chr = videoram[ offset ];
154      UINT8 attr = videoram[ offset + 1 ];
155      UINT8 data = mda.chr_gen[ chr_base + chr * 8 ];
264      UINT8 chr = mda->videoram[ offset ];
265      UINT8 attr = mda->videoram[ offset + 1 ];
266      UINT8 data = mda->chr_gen[ chr_base + chr * 8 ];
156267      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
157268      UINT8 bg = 0;
158269
r10666r10667
181292         break;
182293      }
183294
184      if ( ( i == cursor_x && ( mda.pc_framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 )
295      if ( ( i == cursor_x && ( mda->framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 )
185296      {
186297         data = 0xFF;
187298      }
r10666r10667
214325
215326static MC6845_UPDATE_ROW( mda_text_blink_update_row )
216327{
217   UINT8 *videoram = mda.videoram;
328   isa8_mda_device   *mda = downcast<isa8_mda_device *>(device->owner());
218329   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
219330   UINT16   chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra;
220331   int i;
221   running_machine *machine = device->machine;
222332
223333   if ( y == 0 ) MDA_LOG(1,"mda_text_blink_update_row",("\n"));
224334   for ( i = 0; i < x_count; i++ )
225335   {
226336      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
227      UINT8 chr = videoram[ offset ];
228      UINT8 attr = videoram[ offset + 1 ];
229      UINT8 data = mda.chr_gen[ chr_base + chr * 8 ];
337      UINT8 chr = mda->videoram[ offset ];
338      UINT8 attr = mda->videoram[ offset + 1 ];
339      UINT8 data = mda->chr_gen[ chr_base + chr * 8 ];
230340      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
231341      UINT8 bg = 0;
232342
r10666r10667
256366
257367      if ( i == cursor_x )
258368      {
259         if ( mda.pc_framecnt & 0x08 )
369         if ( mda->framecnt & 0x08 )
260370         {
261371            data = 0xFF;
262372         }
263373      }
264374      else
265375      {
266         if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x10 ) )
376         if ( ( attr & 0x80 ) && ( mda->framecnt & 0x10 ) )
267377         {
268378            data = 0x00;
269379         }
r10666r10667
291401
292402static MC6845_UPDATE_ROW( mda_update_row )
293403{
294   if ( mda.update_row )
404   isa8_mda_device   *mda  = downcast<isa8_mda_device *>(device->owner());
405   if ( mda->update_row )
295406   {
296      mda.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
407      mda->update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
297408   }
298409}
299410
300411
301412static WRITE_LINE_DEVICE_HANDLER( mda_hsync_changed )
302413{
303   mda.hsync = state ? 1 : 0;
414   isa8_mda_device   *mda  = downcast<isa8_mda_device *>(device->owner());
415   mda->hsync = state ? 1 : 0;
304416}
305417
306418
307419static WRITE_LINE_DEVICE_HANDLER( mda_vsync_changed )
308420{
309   mda.vsync = state ? 0x80 : 0;
421   isa8_mda_device   *mda  = downcast<isa8_mda_device *>(device->owner());
422   mda->vsync = state ? 0x80 : 0;
310423   if ( state )
311424   {
312      mda.pc_framecnt++;
425      mda->framecnt++;
313426   }
314427}
315428
r10666r10667
317430/*
318431 *  rW  MDA mode control register (see #P138)
319432 */
320static void mda_mode_control_w(running_machine *machine, int data)
433static WRITE8_DEVICE_HANDLER(mda_mode_control_w)
321434{
435   isa8_mda_device   *mda  = downcast<isa8_mda_device *>(device);
322436   MDA_LOG(1,"MDA_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
323437      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
324   mda.mode_control = data;
438   mda->mode_control = data;
325439
326   switch( mda.mode_control & 0x2a )
440   switch( mda->mode_control & 0x2a )
327441   {
328442   case 0x08:
329      mda.update_row = mda_text_inten_update_row;
443      mda->update_row = mda_text_inten_update_row;
330444      break;
331445   case 0x28:
332      mda.update_row = mda_text_blink_update_row;
446      mda->update_row = mda_text_blink_update_row;
333447      break;
334448   default:
335      mda.update_row = NULL;
449      mda->update_row = NULL;
336450   }
337451}
338452
r10666r10667
348462 *      2-1  reserved
349463 *      0    horizontal drive enable
350464 */
351static int pc_mda_status_r(void)
465static READ8_DEVICE_HANDLER(mda_status_r)
352466{
353    int data = 0x08 | mda.hsync;
354   return data;
467    isa8_mda_device   *mda  = downcast<isa8_mda_device *>(device);
468   return 0x08 | mda->hsync;
355469}
356470
357471
r10666r10667
361475 *      monochrome display adapter
362476 *
363477 *************************************************************************/
364WRITE8_HANDLER ( pc_MDA_w )
478WRITE8_DEVICE_HANDLER ( pc_MDA_w )
365479{
366   device_t *devconf = space->machine->device(MDA_MC6845_NAME);
480   device_t *devconf = device->subdevice(MDA_MC6845_NAME);
367481   switch( offset )
368482   {
369483      case 0: case 2: case 4: case 6:
r10666r10667
373487         mc6845_register_w( devconf, offset, data );
374488         break;
375489      case 8:
376         mda_mode_control_w(space->machine, data);
490         mda_mode_control_w(device, offset, data);
377491         break;
378492   }
379493}
380494
381 READ8_HANDLER ( pc_MDA_r )
495 READ8_DEVICE_HANDLER ( pc_MDA_r )
382496{
383   device_t *devconf = space->machine->device(MDA_MC6845_NAME);
384497   int data = 0xff;
498   device_t *devconf = device->subdevice(MDA_MC6845_NAME);
385499   switch( offset )
386500   {
387501      case 0: case 2: case 4: case 6:
r10666r10667
391505         data = mc6845_register_r( devconf, offset );
392506         break;
393507      case 10:
394         data = pc_mda_status_r();
508         data = mda_status_r(device, offset);
395509         break;
396510      /* 12, 13, 14  are the LPT1 ports */
397511    }
r10666r10667
399513}
400514
401515
402
403516/***************************************************************************
404517
405518  Hercules Display Adapter section (re-uses parts from the MDA section)
406519
407520***************************************************************************/
408521
409static VIDEO_START( pc_hercules );
410522static SCREEN_UPDATE( mc6845_hercules );
411static READ8_HANDLER( pc_hercules_r );
412static WRITE8_HANDLER( pc_hercules_w );
523static READ8_DEVICE_HANDLER( hercules_r );
524static WRITE8_DEVICE_HANDLER( hercules_w );
413525
414526/*
415527When the Hercules changes to graphics mode, the number of pixels per access and
r10666r10667
433545   NULL
434546};
435547
548static GFXDECODE_START( pcherc )
549   GFXDECODE_ENTRY( "hercules:gfx1", 0x0000, pc_16_charlayout, 1, 1 )
550GFXDECODE_END
551
436552MACHINE_CONFIG_FRAGMENT( pcvideo_hercules )
437553   MCFG_SCREEN_ADD( HERCULES_SCREEN_NAME, RASTER)
438554   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
439555   MCFG_SCREEN_RAW_PARAMS(MDA_CLOCK, 882, 0, 720, 370, 0, 350 )
440556   MCFG_SCREEN_UPDATE( mc6845_hercules )
441557
442   MCFG_PALETTE_LENGTH( sizeof(mda_palette) / 3 )
443
444   MCFG_PALETTE_INIT(pc_mda)
445
446558   MCFG_MC6845_ADD( HERCULES_MC6845_NAME, MC6845, MDA_CLOCK/9, mc6845_hercules_intf)
447559
448   MCFG_VIDEO_START( pc_hercules )
560   MCFG_GFXDECODE(pcherc)
449561MACHINE_CONFIG_END
450562
563ROM_START( hercules )
564   ROM_REGION(0x1000,"gfx1", 0)
565   ROM_LOAD("um2301.bin",  0x00000, 0x1000, CRC(0827bdac) SHA1(15f1aceeee8b31f0d860ff420643e3c7f29b5ffc))
566ROM_END
451567
452static VIDEO_START( pc_hercules )
568//**************************************************************************
569//  GLOBAL VARIABLES
570//**************************************************************************
571 
572const device_type ISA8_HERCULES = isa8_hercules_device_config::static_alloc_device_config;
573 
574//**************************************************************************
575//  DEVICE CONFIGURATION
576//**************************************************************************
577 
578//-------------------------------------------------
579//  isa8_mda_device_config - constructor
580//-------------------------------------------------
581 
582isa8_hercules_device_config::isa8_hercules_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
583        : isa8_mda_device_config(mconfig, tag, owner, clock)
453584{
585   m_shortname = "hercules";
586}
587 
588//-------------------------------------------------
589//  static_alloc_device_config - allocate a new
590//  configuration object
591//-------------------------------------------------
592 
593device_config *isa8_hercules_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
594{
595        return global_alloc(isa8_hercules_device_config(mconfig, tag, owner, clock));
596}
597 
598//-------------------------------------------------
599//  alloc_device - allocate a new device object
600//-------------------------------------------------
601 
602device_t *isa8_hercules_device_config::alloc_device(running_machine &machine) const
603{
604        return auto_alloc(&machine, isa8_hercules_device(machine, *this));
605}
606 
607//-------------------------------------------------
608//  machine_config_additions - device-specific
609//  machine configurations
610//-------------------------------------------------
611
612machine_config_constructor isa8_hercules_device_config::machine_config_additions() const
613{
614   return MACHINE_CONFIG_NAME( pcvideo_hercules );
615}
616
617//-------------------------------------------------
618//  rom_region - device-specific ROM region
619//-------------------------------------------------
620
621const rom_entry *isa8_hercules_device_config::rom_region() const
622{
623   return ROM_NAME( hercules );
624}
625
626//**************************************************************************
627//  LIVE DEVICE
628//**************************************************************************
629 
630//-------------------------------------------------
631//  isa8_hercules_device - constructor
632//-------------------------------------------------
633 
634isa8_hercules_device::isa8_hercules_device(running_machine &_machine, const isa8_hercules_device_config &config) :
635        isa8_mda_device(_machine, config),
636      m_config(config)
637{
638}
639 
640//-------------------------------------------------
641//  device_start - device-specific startup
642//-------------------------------------------------
643 
644void isa8_hercules_device::device_start()
645{       
454646   int buswidth;
455647   address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM);
456648
457649   buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width;
458650   switch(buswidth)
459651   {
460   case 8:
461      memory_install_readwrite_bank(space, 0xb0000, 0xbffff, 0, 0, "bank11" );
462      memory_install_read8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_hercules_r );
463      memory_install_write8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_hercules_w );
464      break;
652      case 8:
653         memory_install_readwrite_bank(space, 0xb0000, 0xbffff, 0, 0, "bank_hercules" );
654         memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, hercules_r, hercules_w );
655         break;
465656
466   default:
467      fatalerror("Hercules: Bus width %d not supported", buswidth);
468      break;
657      default:
658         fatalerror("MDA: Bus width %d not supported", buswidth);
659         break;
469660   }
470661
471   memset( &mda, 0, sizeof(mda));
472   mda.update_row = NULL;
473   mda.chr_gen = machine->region( "gfx1" )->base();
662   videoram = auto_alloc_array(machine, UINT8, 0x10000);
663   
664   memory_set_bankptr(machine,"bank_hercules", videoram);
474665
475   mda.videoram = auto_alloc_array(machine, UINT8, 0x10000);
476   memory_set_bankptr(machine,"bank11", mda.videoram);
666   /* Initialise the mda palette */
667   for(int i = 0; i < (sizeof(mda_palette) / 3); i++)
668      palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]);   
477669}
670 
671//-------------------------------------------------
672//  device_reset - device-specific reset
673//-------------------------------------------------
674 
675void isa8_hercules_device::device_reset()
676{
677   isa8_mda_device::device_reset();
678   configuration_switch = 0;
478679
680   astring tempstring;
681   chr_gen = machine->region(subtag(tempstring, "gfx1"))->base();   
682}
479683
480684/***************************************************************************
481685  Draw graphics with 720x348 pixels (default); so called Hercules gfx.
r10666r10667
486690
487691static MC6845_UPDATE_ROW( hercules_gfx_update_row )
488692{
489   UINT8 *videoram = mda.videoram;
693   isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner());
490694   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
491   UINT16   gfx_base = ( ( mda.mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 );
695   UINT16   gfx_base = ( ( herc->mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 );
492696   int i;
493   running_machine *machine = device->machine;
494
495697   if ( y == 0 ) MDA_LOG(1,"hercules_gfx_update_row",("\n"));
496698   for ( i = 0; i < x_count; i++ )
497699   {
498      UINT8   data = videoram[ gfx_base + ( ( ma + i ) << 1 ) ];
700      UINT8   data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) ];
499701
500702      *p = ( data & 0x80 ) ? 2 : 0; p++;
501703      *p = ( data & 0x40 ) ? 2 : 0; p++;
r10666r10667
506708      *p = ( data & 0x02 ) ? 2 : 0; p++;
507709      *p = ( data & 0x01 ) ? 2 : 0; p++;
508710
509      data = videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ];
711      data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ];
510712
511713      *p = ( data & 0x80 ) ? 2 : 0; p++;
512714      *p = ( data & 0x40 ) ? 2 : 0; p++;
r10666r10667
522724
523725static SCREEN_UPDATE( mc6845_hercules )
524726{
525   device_t *devconf = screen->machine->device(HERCULES_MC6845_NAME);
727   device_t *devconf = screen->owner()->subdevice(HERCULES_MC6845_NAME);
728
526729   mc6845_update( devconf, bitmap, cliprect );
527730   return 0;
528731}
529732
530733
531static void hercules_mode_control_w(running_machine *machine, int data)
734static WRITE8_DEVICE_HANDLER(hercules_mode_control_w)
532735{
533   device_t *devconf = machine->device(HERCULES_MC6845_NAME);
736   isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner());
534737
535738   MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
536739      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
537   mda.mode_control = data;
740   herc->mode_control = data;
538741
539   switch( mda.mode_control & 0x2a )
742   switch( herc->mode_control & 0x2a )
540743   {
541744   case 0x08:
542      mda.update_row = mda_text_inten_update_row;
745      herc->update_row = mda_text_inten_update_row;
543746      break;
544747   case 0x28:
545      mda.update_row = mda_text_blink_update_row;
748      herc->update_row = mda_text_blink_update_row;
546749      break;
547750   case 0x0A:          /* Hercules modes */
548751   case 0x2A:
549      mda.update_row = hercules_gfx_update_row;
752      herc->update_row = hercules_gfx_update_row;
550753      break;
551754   default:
552      mda.update_row = NULL;
755      herc->update_row = NULL;
553756   }
554757
555   mc6845_set_clock( devconf, mda.mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 );
556   mc6845_set_hpixels_per_column( devconf, mda.mode_control & 0x02 ? 16 : 9 );
758   mc6845_set_clock( device, herc->mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 );
759   mc6845_set_hpixels_per_column( device, herc->mode_control & 0x02 ? 16 : 9 );
557760}
558761
559762
560static void hercules_config_w(running_machine *machine, int data)
763static WRITE8_DEVICE_HANDLER(hercules_config_w)
561764{
765   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device);
562766   MDA_LOG(1,"HGC_config_w",("$%02x\n", data));
563   mda.configuration_switch = data;
767   herc->configuration_switch = data;
564768}
565769
566770
567static WRITE8_HANDLER ( pc_hercules_w )
771static WRITE8_DEVICE_HANDLER ( hercules_w )
568772{
569   device_t *devconf = space->machine->device(HERCULES_MC6845_NAME);
570
773   device_t *devconf = device->subdevice(HERCULES_MC6845_NAME);
571774   switch( offset )
572775   {
573776   case 0: case 2: case 4: case 6:
r10666r10667
577780      mc6845_register_w( devconf, offset, data );
578781      break;
579782   case 8:
580      hercules_mode_control_w(space->machine, data);
783      hercules_mode_control_w(devconf, offset, data);
581784      break;
582785   case 15:
583      hercules_config_w(space->machine, data);
786      hercules_config_w(device, offset, data);
584787      break;
585788   }
586789}
r10666r10667
597800 *      2-1  reserved
598801 *      0    horizontal drive enable
599802 */
600static int pc_hercules_status_r(void)
803static READ8_DEVICE_HANDLER(hercules_status_r)
601804{
602   int data = mda.vsync | 0x08 | mda.hsync;
603   return data;
805   isa8_hercules_device *herc  = downcast<isa8_hercules_device *>(device);
806   return herc->vsync | 0x08 | herc->hsync;
604807}
605808
606809
607static READ8_HANDLER ( pc_hercules_r )
810static READ8_DEVICE_HANDLER ( hercules_r )
608811{
609   device_t *devconf = space->machine->device(HERCULES_MC6845_NAME);
610812   int data = 0xff;
611
813   device_t *devconf = device->subdevice(HERCULES_MC6845_NAME);
612814   switch( offset )
613815   {
614816   case 0: case 2: case 4: case 6:
r10666r10667
618820      data = mc6845_register_r( devconf, offset );
619821      break;
620822   case 10:
621      data = pc_hercules_status_r();
823      data = hercules_status_r(device, offset);
622824      break;
623825      /* 12, 13, 14  are the LPT1 ports */
624826   }
625827   return data;
626828}
627
src/mess/video/pc_mda.h
r10666r10667
1/*
2  MDA vidoe card
3 */
4#define MDA_SCREEN_NAME   "mda_screen"
5#define MDA_MC6845_NAME   "mc6845_mda"
1#pragma once
2 
3#ifndef __PC_MDA_H__
4#define __PC_MDA_H__
5 
6#include "emu.h"
7#include "machine/isa.h"
8#include "video/mc6845.h"
69
7MACHINE_CONFIG_EXTERN( pcvideo_mda );
10//**************************************************************************
11//  TYPE DEFINITIONS
12//**************************************************************************
13 
14// ======================> isa8_mda_device_config
15 
16class isa8_mda_device_config :
17      public device_config,
18      public device_config_isa8_card_interface
19{
20        friend class isa8_device;
21      friend class isa8_hercules_device_config;
22 
23        // construction/destruction
24        isa8_mda_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
25 
26public:
27        // allocators
28        static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
29        virtual device_t *alloc_device(running_machine &machine) const;
30     
31      // optional information overrides
32      virtual machine_config_constructor machine_config_additions() const;
33      virtual const rom_entry *rom_region() const;     
34};
35 
36 
37// ======================> isa8_mda_device
38 
39class isa8_mda_device :
40      public device_t,
41      public device_isa8_card_interface
42{
43        friend class isa8_mda_device_config;
44      friend class isa8_hercules_device_config;     
45      friend class isa8_hercules_device;
46 
47        // construction/destruction
48        isa8_mda_device(running_machine &_machine, const isa8_mda_device_config &config);
849
50protected:
51        // device-level overrides
52        virtual void device_start();
53        virtual void device_reset();
954
10/*
11  Hercules video card
12 */
13#define HERCULES_SCREEN_NAME "hercules_screen"
14#define HERCULES_MC6845_NAME "mc6845_hercules"
55private:
56        // internal state
57        const isa8_mda_device_config &m_config;
1558
16MACHINE_CONFIG_EXTERN( pcvideo_hercules );
59public:
60      int  framecnt;
1761
62      UINT8 mode_control;
63     
64      mc6845_update_row_func  update_row;
65      UINT8   *chr_gen;
66      UINT8   vsync;
67      UINT8   hsync;
68      UINT8  *videoram;
69};
70 
71 
72// device type definition
73extern const device_type ISA8_MDA;
74
75// ======================> isa8_hercules_device_config
76 
77class isa8_hercules_device_config :
78      public isa8_mda_device_config
79{
80        friend class isa8_hercules_device;
81      friend class isa8_mda_device;
82 
83        // construction/destruction
84        isa8_hercules_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
85 
86public:
87        // allocators
88        static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
89        virtual device_t *alloc_device(running_machine &machine) const;
90     
91      // optional information overrides
92      virtual machine_config_constructor machine_config_additions() const;
93      virtual const rom_entry *rom_region() const;     
94};
95 
96 
97// ======================> isa8_hercules_device
98 
99class isa8_hercules_device :
100      public isa8_mda_device
101{
102        friend class isa8_hercules_device_config;
103      friend class isa8_mda_device_config;
104 
105        // construction/destruction
106        isa8_hercules_device(running_machine &_machine, const isa8_hercules_device_config &config);
107
108protected:
109        // device-level overrides
110        virtual void device_start();
111        virtual void device_reset();
112 
113private:
114        // internal state
115        const isa8_hercules_device_config &m_config;
116
117public:
118      UINT8 configuration_switch; //hercules
119};
120 
121 
122// device type definition
123extern const device_type ISA8_HERCULES;
124
125#endif  /* __PC_MDA_H__ */
src/mess/mess.mak
r10666r10667
529529   $(MESS_MACHINE)/i8271.o      \
530530   $(MESS_MACHINE)/i8355.o      \
531531   $(MESS_MACHINE)/ieee488.o   \
532   $(MESS_MACHINE)/isa.o      \
532533   $(MESS_MACHINE)/kb3600.o   \
533534   $(MESS_MACHINE)/kr2376.o   \
534535   $(MESS_MACHINE)/mc6843.o   \
src/mess/drivers/pc.c
r10666r10667
169169#include "machine/kb_keytro.h"
170170#include "machine/ram.h"
171171
172#include "machine/isa.h"
173
172174#define ym3812_StdClock 3579545
173175
174176/*
r10666r10667
15581560   8*8               /* every char takes 8 bytes */
15591561};
15601562
1561static GFXDECODE_START( pcmda )
1562   GFXDECODE_ENTRY( "gfx1", 0x0000, pc_16_charlayout, 1, 1 )
1563   GFXDECODE_ENTRY( "gfx1", 0x1000, pc_8_charlayout, 1, 1 )
1564GFXDECODE_END
1565
15661563static MACHINE_CONFIG_START( pcmda, pc_state )
15671564   /* basic machine hardware */
15681565   MCFG_CPU_ADD("maincpu", V20, 4772720)
r10666r10667
15881585   MCFG_INS8250_ADD( "ins8250_2", ibm5150_com_interface[2] )         /* TODO: Verify model */
15891586   MCFG_INS8250_ADD( "ins8250_3", ibm5150_com_interface[3] )         /* TODO: Verify model */
15901587
1591   /* video hardware */
1592   MCFG_FRAGMENT_ADD( pcvideo_mda )
1593   MCFG_GFXDECODE(pcmda)
1588   MCFG_PALETTE_LENGTH( 256 )
1589     
1590   MCFG_ISA8_BUS_ADD("isa","maincpu")
1591   MCFG_ISA8_BUS_DEVICE("isa", 0, "mda", ISA8_MDA)
15941592
15951593   /* sound hardware */
15961594   MCFG_SPEAKER_STANDARD_MONO("mono")
r10666r10667
16291627MACHINE_CONFIG_END
16301628
16311629
1632static GFXDECODE_START( pcherc )
1633   GFXDECODE_ENTRY( "gfx1", 0x0000, pc_16_charlayout, 1, 1 )
1634GFXDECODE_END
1635
16361630static MACHINE_CONFIG_START( pcherc, pc_state )
16371631   /* basic machine hardware */
16381632   MCFG_CPU_ADD("maincpu", V20, 4772720)
r10666r10667
16561650   MCFG_INS8250_ADD( "ins8250_2", ibm5150_com_interface[2] )         /* TODO: Verify model */
16571651   MCFG_INS8250_ADD( "ins8250_3", ibm5150_com_interface[3] )         /* TODO: Verify model */
16581652
1659   /* video hardware */
1660   MCFG_FRAGMENT_ADD( pcvideo_hercules )
1661   MCFG_GFXDECODE(pcherc)
1653   MCFG_PALETTE_LENGTH( 256 )   
1654   
1655   MCFG_ISA8_BUS_ADD("isa","maincpu")
1656   MCFG_ISA8_BUS_DEVICE("isa", 0, "hercules", ISA8_HERCULES)
16621657
16631658   /* sound hardware */
16641659   MCFG_SPEAKER_STANDARD_MONO("mono")
r10666r10667
29622957   ROM_REGION(0x100000,"maincpu", 0)
29632958   ROM_LOAD("wdbios.rom",  0xc8000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a)) /* WDC IDE Superbios 2.0 (06/28/89) Expansion Rom C8000-C9FFF  */
29642959   ROM_LOAD("pcxt.rom",    0xfe000, 0x02000, CRC(031aafad) SHA1(a641b505bbac97b8775f91fe9b83d9afdf4d038f))
2965
2966   /* IBM 1501981(CGA) and 1501985(MDA) Character rom */
2967   ROM_REGION(0x08100,"gfx1", 0)
2968   ROM_LOAD("5788005.u33", 0x00000, 0x02000, CRC(0bf56d70) SHA1(c2a8b10808bf51a3c123ba3eb1e9dd608231916f)) /* "AMI 8412PI // 5788005 // (C) IBM CORP. 1981 // KOREA" */
29692960ROM_END
29702961
29712962
r10666r10667
29732964   ROM_REGION(0x100000,"maincpu", 0)
29742965   ROM_LOAD("wdbios.rom",  0xc8000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a)) /* WDC IDE Superbios 2.0 (06/28/89) Expansion Rom C8000-C9FFF  */
29752966   ROM_LOAD("pcxt.rom",    0xfe000, 0x02000, CRC(031aafad) SHA1(a641b505bbac97b8775f91fe9b83d9afdf4d038f))
2976   ROM_REGION(0x1000,"gfx1", 0)
2977   ROM_LOAD("um2301.bin",  0x00000, 0x1000, CRC(0827bdac) SHA1(15f1aceeee8b31f0d860ff420643e3c7f29b5ffc))
29782967ROM_END
29792968
29802969

Previous 15994 Revisions Next


© 1998-2018 The MESS Team