Previous 15994 Revisions Next

r2059 Saturday 22nd March, 2008 at 16:42:35 UTC by Wilbert Pol
[PCMDA] Updated pc_mda code to use the mc6845 device.
[PCHERC] Temporary hacked up driver to test hercules emulation.
[src/mess/drivers]pc.c
[src/mess/video]pc_mda.c pc_mda.h

src/mess/video/pc_mda.c
r2058r2059
55***************************************************************************/
66
77#include "driver.h"
8#include "deprecat.h"
98#include "pc_mda.h"
10#include "pc_cga.h" //for the cga palette hack
11#include "includes/crtc6845.h"
9#include "pc_video.h"
10#include "video/mc6845.h"
1211
12#define VERBOSE_MDA   0      /* MDA (Monochrome Display Adapter) */
1313
14#define VERBOSE_MDA 0      /* MDA (Monochrome Display Adapter) */
15
1614#define MDA_LOG(N,M,A) \
1715   if(VERBOSE_MDA>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; }
1816
r2058r2059
2321   { 0x00,0xff,0x00 }
2422};
2523
26const gfx_layout pc_mda_charlayout =
27{
28   9,32,               /* 9 x 32 characters (9 x 15 is the default, but..) */
29   256,               /* 256 characters */
30   1,                      /* 1 bits per pixel */
31   { 0 },                  /* no bitplanes; 1 bit per pixel */
32   /* x offsets */
33   { 0,1,2,3,4,5,6,7,7 },   /* pixel 7 repeated only for char code 176 to 223 */
34   /* y offsets */
35   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
36     16384+0*8, 16384+1*8, 16384+2*8, 16384+3*8,
37     16384+4*8, 16384+5*8, 16384+6*8, 16384+7*8,
38     0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
39     16384+0*8, 16384+1*8, 16384+2*8, 16384+3*8,
40     16384+4*8, 16384+5*8, 16384+6*8, 16384+7*8 },
41   8*8                /* every char takes 8 bytes (upper half) */
42};
24static struct {
25   UINT8 status;
4326
44GFXDECODE_START( pc_mda )
45   GFXDECODE_ENTRY( REGION_GFX1, 0x0000, pc_mda_charlayout, 0, 256 )
46GFXDECODE_END
27   int pc_framecnt;
4728
48/* to be done:
49   only 2 digital color lines to mda/hercules monitor
50   (maximal 4 colors)
51   PC200 uses different attributes from IBM.
52*/
53const unsigned short mda_colortable[] =
54{
55   0, 0, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 0, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
56   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
57   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
58   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
59   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
60   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
61   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
62   2, 0, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 2, 0, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
63/* nb: This---------------------------------------------^ should refer to a "dim" colour which
64 * we don't do yet */
29   UINT8 mode_control, configuration_switch; //hercules
6530
66/* flashing is done by dirtying the videoram buffer positions with attr bit #7 set
67 * These attributes are used for the flashing characters when they're visible. */
68   0, 0, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 0, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
69   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
70   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
71   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
72   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
73   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
74   0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
75   2, 0, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 2, 0, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10, 0,10,
31   gfx_element *gfx_char[4];
7632
77/* the two colors for HGC graphics */
78   0, 10
79};
33   mc6845_update_row_func  update_row;
34   UINT8   *chr_gen;
35   UINT8   vsync;
36   UINT8   hsync;
37} mda;
8038
8139/* Initialise the mda palette */
8240PALETTE_INIT( pc_mda )
8341{
8442   int i;
85   for(i = 0; i < (sizeof(cga_palette) / 3); i++)
86      palette_set_color_rgb(machine, i, cga_palette[i][0], cga_palette[i][1], cga_palette[i][2]);
43   for(i = 0; i < (sizeof(mda_palette) / 3); i++)
44      palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]);
8745}
8846
89static struct
90{
91   UINT8 status;
47static VIDEO_START( pc_mda );
48static VIDEO_UPDATE( mc6845_mda );
49static READ8_HANDLER( pc_MDA_r );
50static WRITE8_HANDLER( pc_MDA_w );
51static MC6845_UPDATE_ROW( mda_update_row );
52static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed );
53static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed );
9254
93   int pc_blink;
94   int pc_framecnt;
55static const mc6845_interface mc6845_mda_intf = {
56   MDA_SCREEN_NAME,   /* screen number */
57   16257000/9 /*?*/,   /* clock */
58   9,               /* number of pixels per video memory address */
59   NULL,            /* begin_update */
60   mda_update_row,      /* update_row */
61   NULL,            /* end_update */
62   NULL,            /* on_de_changed */
63   mda_hsync_changed,   /* on_hsync_changed */
64   mda_vsync_changed   /* on_vsync_changed */
65};
9566
96   UINT8 mode_control, configuration_switch; //hercules
67MACHINE_DRIVER_START( pcvideo_mda )
68   MDRV_SCREEN_ADD( MDA_SCREEN_NAME, RASTER)
69   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
70   MDRV_SCREEN_RAW_PARAMS(16257000, 882, 0, 720, 370, 0, 350 )
71   MDRV_PALETTE_LENGTH( sizeof(mda_palette) / 3 )
9772
98   gfx_element *gfx_char[4];
99} mda;
73   MDRV_PALETTE_INIT(pc_mda)
10074
75   MDRV_DEVICE_ADD( MDA_MC6845_NAME, MC6845)
76   MDRV_DEVICE_CONFIG( mc6845_mda_intf )
77
78   MDRV_VIDEO_START( pc_mda )
79   MDRV_VIDEO_UPDATE( mc6845_mda)
80MACHINE_DRIVER_END
81
82
10183/***************************************************************************
10284
10385  Monochrome Display Adapter (MDA) section
10486
10587***************************************************************************/
10688
107/***************************************************************************
108  Mark all text positions with attribute bit 7 set dirty
109 ***************************************************************************/
110static void pc_mda_blink_textcolors(int on)
89VIDEO_START( pc_mda )
11190{
112   int offs, size;
91   int buswidth;
11392
114   if (mda.pc_blink == on) return;
93   buswidth = cputype_databus_width(machine->config->cpu[0].type, ADDRESS_SPACE_PROGRAM);
94   switch(buswidth)
95   {
96      case 8:
97         memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0x07000, SMH_BANK11 );
98         memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0x07000, pc_video_videoram_w );
99         memory_install_read8_handler(0, ADDRESS_SPACE_IO, 0x3b0, 0x3bf, 0, 0, pc_MDA_r );
100         memory_install_write8_handler(0, ADDRESS_SPACE_IO, 0x3b0, 0x3bf, 0, 0, pc_MDA_w );
101         break;
115102
116    mda.pc_blink = on;
117   offs = (mscrtc6845_get_start(mscrtc6845)*2)% videoram_size;
118   size = mscrtc6845_get_char_lines(mscrtc6845)*mscrtc6845_get_char_columns(mscrtc6845);
119}
103      default:
104         fatalerror("MDA:  Bus width %d not supported\n", buswidth);
105         break;
106   }
120107
121extern void pc_mda_timer(void)
122{
123   if( ((++mda.pc_framecnt & 63) == 63) ) {
124      pc_mda_blink_textcolors(mda.pc_framecnt&64);
125   }
108   memset( &mda, 0, sizeof(mda));
109   mda.update_row = NULL;
110   mda.chr_gen = memory_region( REGION_GFX1 );
111
112   videoram_size = 0x1000;   /* This is actually 0x1000 in reality */
113   videoram = auto_malloc(videoram_size);
114   memory_set_bankptr(11, videoram);
126115}
127116
128void pc_mda_cursor(struct mscrtc6845_cursor *cursor)
129{
117
118static VIDEO_UPDATE( mc6845_mda ) {
119   device_config   *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, MDA_MC6845_NAME);
120   mc6845_update( devconf, bitmap, cliprect );
121   return 0;
130122}
131123
132static const struct mscrtc6845_config config= { 14318180 /*?*/, pc_mda_cursor };
133124
125/***************************************************************************
126  Draw text mode with 80x25 characters (default) and intense background.
127  The character cell size is 9x15. Column 9 is column 8 repeated for
128  character codes 176 to 223.
129***************************************************************************/
134130
135/* This code seems to go through hoops to accomodate differing GfxElement
136 * layouts.  What ugly crap */
137static void pc_mda_init_video_internal(int gfx_char, int gfx_char_mask)
138{
139   int i, y;
131static MC6845_UPDATE_ROW( mda_text_inten_update_row ) {
132   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
133   UINT16   chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra;
134   int i;
140135
141   /* Support up to 4 fonts for PC200 */
142   for (i = 0; i < 4; i++)
143   {
144      mda.gfx_char[i] = Machine->gfx[gfx_char + (i & gfx_char_mask)];
145   }
136   if ( y == 0 ) logerror("mda_text_inten_update_row\n");
137   for ( i = 0; i < x_count; i++ ) {
138      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
139      UINT8 chr = videoram[ offset ];
140      UINT8 attr = videoram[ offset + 1 ];
141      UINT8 data = mda.chr_gen[ chr_base + chr * 8 ];
142      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
143      UINT8 bg = 0;
146144
147   /* remove pixel column 9 for character codes 0 - 191 and 224 - 255 */
148   for (i = 0; i < 256; i++)
149   {
150      if (i < 191 || i > 223)
151      {
152         for (y = 0; y < Machine->gfx[gfx_char]->height; y++)
153            Machine->gfx[gfx_char]->gfxdata[(i * Machine->gfx[gfx_char]->height + y) * Machine->gfx[gfx_char]->width + 8] = 0;
145      if ( ( attr & ~0x88 ) == 0 ) {
146         data = 0x00;
154147      }
148
149      switch( attr ) {
150      case 0x70:
151         bg = 2;
152         fg = 0;
153         break;
154      case 0x78:
155         bg = 2;
156         fg = 1;
157         break;
158      case 0xF0:
159         bg = 3;
160         fg = 0;
161         break;
162      case 0xF8:
163         bg = 3;
164         fg = 1;
165         break;
166      }
167
168      if ( i == cursor_x || ( attr & 0x07 ) == 0x01 ) {
169         data = 0xFF;
170      }
171
172      *p = ( data & 0x80 ) ? fg : bg; p++;
173      *p = ( data & 0x40 ) ? fg : bg; p++;
174      *p = ( data & 0x20 ) ? fg : bg; p++;
175      *p = ( data & 0x10 ) ? fg : bg; p++;
176      *p = ( data & 0x08 ) ? fg : bg; p++;
177      *p = ( data & 0x04 ) ? fg : bg; p++;
178      *p = ( data & 0x02 ) ? fg : bg; p++;
179      *p = ( data & 0x01 ) ? fg : bg; p++;
180      if ( ( chr & 0xE0 ) == 0xC0 ) {
181         *p = ( data & 0x01 ) ? fg : bg; p++;
182      } else {
183         *p = bg; p++;
184      }
155185   }
156186}
157187
158void pc_mda_init_video(void)
159{
160   pc_mda_init_video_internal(0, 0);
161}
162188
163void pc_mda_europc_init(void)
164{
165   pc_mda_init_video_internal(4, 3);
166}
189/***************************************************************************
190  Draw text mode with 80x25 characters (default) and blinking characters.
191  The character cell size is 9x15. Column 9 is column 8 repeated for
192  character codes 176 to 223.
193***************************************************************************/
167194
168VIDEO_START( pc_mda )
169{
170   int buswidth;
195static MC6845_UPDATE_ROW( mda_text_blink_update_row ) {
196   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
197   UINT16   chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra;
198   int i;
171199
172   buswidth = cputype_databus_width(machine->config->cpu[0].type, ADDRESS_SPACE_PROGRAM);
173   switch(buswidth)
174   {
175      case 8:
176         memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xbffff, 0, 0, SMH_BANK11 );
177         memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xbffff, 0, 0, pc_video_videoram_w );
178         memory_install_read8_handler(0, ADDRESS_SPACE_IO, 0x3b0, 0x3bf, 0, 0, pc_MDA_r );
179         memory_install_write8_handler(0, ADDRESS_SPACE_IO, 0x3b0, 0x3bf, 0, 0, pc_MDA_w );
200   if ( y == 0 ) logerror("mda_text_blink_update_row\n");
201   for ( i = 0; i < x_count; i++ ) {
202      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
203      UINT8 chr = videoram[ offset ];
204      UINT8 attr = videoram[ offset + 1 ];
205      UINT8 data = mda.chr_gen[ chr_base + chr * 8 ];
206      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
207      UINT8 bg = 0;
208
209      if ( ( attr & ~0x88 ) == 0 ) {
210         data = 0x00;
211      }
212
213      switch( attr ) {
214      case 0x70:
215      case 0xF0:
216         bg = 2;
217         fg = 0;
180218         break;
219      case 0x78:
220      case 0xF8:
221         bg = 2;
222         fg = 1;
223         break;
224      }
181225
182      default:
183         fatalerror("MDA:  Bus width %d not supported\n", buswidth);
184         break;
226      if ( i == cursor_x ) {
227         data = 0xFF;
228      } else {
229         if ( ( attr & 0x07 ) == 0x01 ) {
230            data = 0xFF;
231         }
232         if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x40 ) ) {
233            data = 0x00;
234         }
235      }
236
237      *p = ( data & 0x80 ) ? fg : bg; p++;
238      *p = ( data & 0x40 ) ? fg : bg; p++;
239      *p = ( data & 0x20 ) ? fg : bg; p++;
240      *p = ( data & 0x10 ) ? fg : bg; p++;
241      *p = ( data & 0x08 ) ? fg : bg; p++;
242      *p = ( data & 0x04 ) ? fg : bg; p++;
243      *p = ( data & 0x02 ) ? fg : bg; p++;
244      *p = ( data & 0x01 ) ? fg : bg; p++;
245      if ( ( chr & 0xE0 ) == 0xC0 ) {
246         *p = ( data & 0x01 ) ? fg : bg; p++;
247      } else {
248         *p = bg; p++;
249      }
185250   }
251}
186252
187253
188   videoram_size = 0x10000;
189   videoram = auto_malloc(videoram_size);
190   memory_set_bankptr(11, videoram);
254static MC6845_UPDATE_ROW( mda_update_row ) {
255   if ( mda.update_row ) {
256      mda.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
257   }
258}
191259
192   pc_mda_init_video();
193   pc_video_start(&config, pc_mda_choosevideomode, videoram_size);
260
261static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed ) {
262   mda.hsync = hsync ? 1 : 0;
194263}
195264
265
266static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed ) {
267   mda.vsync = vsync ? 0x80 : 0;
268   if ( vsync ) {
269      mda.pc_framecnt++;
270   }
271}
272
273
196274/*
197275 *   rW   MDA mode control register (see #P138)
198276 */
199static void hercules_mode_control_w(int data)
277static void mda_mode_control_w(int data)
200278{
201279   MDA_LOG(1,"MDA_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
202280      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
203281   mda.mode_control = data;
282
283   switch( mda.mode_control & 0x2a ) {
284   case 0x08:
285      mda.update_row = mda_text_inten_update_row;
286      break;
287   case 0x28:
288      mda.update_row = mda_text_blink_update_row;
289      break;
290   default:
291      mda.update_row = NULL;
292   }
204293}
205294
295
206296/*   R-   CRT status register (see #P139)
207297 *      (EGA/VGA) input status 1 register
208298 *      7    HGC vertical sync in progress
r2058r2059
221311   return data;
222312}
223313
224static void hercules_config_w(int data)
225{
226   MDA_LOG(1,"HGC_config_w",("$%02x\n", data));
227    mda.configuration_switch = data;
228}
229314
230315/*************************************************************************
231316 *
r2058r2059
235320 *************************************************************************/
236321WRITE8_HANDLER ( pc_MDA_w )
237322{
323   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, MDA_MC6845_NAME);
238324   switch( offset )
239325   {
240326      case 0: case 2: case 4: case 6:
241         mscrtc6845_port_w(mscrtc6845, 0, data);
327         mc6845_address_w( devconf, offset, data );
242328         break;
243329      case 1: case 3: case 5: case 7:
244         mscrtc6845_port_w(mscrtc6845, 1, data);
330         mc6845_register_w( devconf, offset, data );
245331         break;
246332      case 8:
247         hercules_mode_control_w(data);
333         mda_mode_control_w(data);
248334         break;
249      case 15:
250         hercules_config_w(data);
251         break;
252335   }
253336}
254337
255338 READ8_HANDLER ( pc_MDA_r )
256339{
340   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, MDA_MC6845_NAME);
257341   int data = 0xff;
258342   switch( offset )
259343   {
260344      case 0: case 2: case 4: case 6:
261         data = mscrtc6845_port_r(mscrtc6845,0);
345         /* return last written mc6845 address value here? */
262346         break;
263347      case 1: case 3: case 5: case 7:
264         data = mscrtc6845_port_r(mscrtc6845,1);
348         data = mc6845_register_r( devconf, offset );
265349         break;
266350      case 10:
267351         data = pc_mda_status_r();
r2058r2059
271355   return data;
272356}
273357
358
359
274360/***************************************************************************
275  Draw text mode with 80x25 characters (default) and intense background.
276  The character cell size is 9x15. Column 9 is column 8 repeated for
277  character codes 176 to 223.
361
362  Hercules Display Adapter section (re-uses parts from the MDA section)
363
278364***************************************************************************/
279static void mda_text_inten(bitmap_t *bitmap, struct mscrtc6845 *crtc)
280{
281   int sx, sy;
282   int   offs = mscrtc6845_get_start(crtc)*2;
283   int lines = mscrtc6845_get_char_lines(crtc);
284   int height = mscrtc6845_get_char_height(crtc);
285   int columns = mscrtc6845_get_char_columns(crtc);
286   int char_width;
287   rectangle r;
288   struct mscrtc6845_cursor cursor;
289   UINT8 attr;
290   const device_config *screen = video_screen_first(Machine->config);
291   int screen_width = video_screen_get_width(screen);
292365
293   char_width = screen_width / 80;
366static VIDEO_START( pc_hercules );
367static VIDEO_UPDATE( mc6845_hercules );
368static READ8_HANDLER( pc_hercules_r );
369static WRITE8_HANDLER( pc_hercules_w );
294370
295   mscrtc6845_time(crtc);
296   mscrtc6845_get_cursor(crtc, &cursor);
371/*
372When the Hercules changes to graphics mode, the number of pixels per access and
373clock divider should be changed. The currect mc6845 implementation does not
374allow this.
297375
298   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
299   {
300      for (sx=0, r.min_x=0, r.max_x = char_width-1; sx<columns;
301          sx++, offs=(offs+2)&0x3fff, r.min_x += char_width, r.max_x += char_width)
302      {
303         attr = videoram[offs+1];
304         drawgfx(bitmap, mda.gfx_char[CGA_FONT], videoram[offs], attr,
305               0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0);
306         /* Underlining */
307         if ((attr & 7) == 1)
308            plot_box(bitmap, r.min_x, r.min_y + 12, char_width,
309               1, Machine->pens[2 + (attr & 8)]);
376The divder/pixels per 6845 clock is 9 for text mode and 16 for graphics mode.
377*/
310378
311         if (cursor.on&&(mda.pc_framecnt&32)&&(offs==cursor.pos*2)) {
312            int k=height-cursor.top;
313            rectangle rect2=r;
314            rect2.min_y+=cursor.top;
315            if (cursor.bottom<height) k=cursor.bottom-cursor.top+1;
379static const mc6845_interface mc6845_hercules_intf = {
380   HERCULES_SCREEN_NAME,   /* screen number */
381   16257000/9 /*?*/,      /* clock */
382   9,                  /* number of pixels per video memory address */
383   NULL,               /* begin_update */
384   mda_update_row,         /* update_row */
385   NULL,               /* end_update */
386   NULL,               /* on_de_changed */
387   mda_hsync_changed,      /* on_hsync_changed */
388   mda_vsync_changed      /* on_vsync_changed */
389};
316390
317            if (k>0)
318               plot_box(bitmap, r.min_x,
319                      r.min_y+cursor.top,
320                      char_width, k, Machine->pens[2/*?*/]);
321         }
322      }
323   }
324}
391MACHINE_DRIVER_START( pcvideo_hercules )
392   MDRV_SCREEN_ADD( HERCULES_SCREEN_NAME, RASTER)
393   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
394   MDRV_SCREEN_RAW_PARAMS(16257000, 882, 0, 720, 370, 0, 350 )
395   MDRV_PALETTE_LENGTH( sizeof(mda_palette) / 3 )
325396
397   MDRV_PALETTE_INIT(pc_mda)
326398
327/***************************************************************************
328  Draw text mode with 80x25 characters (default) and blinking characters.
329  The character cell size is 9x15. Column 9 is column 8 repeated for
330  character codes 176 to 223.
331***************************************************************************/
332static void mda_text_blink(bitmap_t *bitmap, struct mscrtc6845 *crtc)
333{
334   int sx, sy;
335   int   offs = mscrtc6845_get_start(crtc)*2;
336   int lines = mscrtc6845_get_char_lines(crtc);
337   int height = mscrtc6845_get_char_height(crtc);
338   int columns = mscrtc6845_get_char_columns(crtc);
339   rectangle r;
340   struct mscrtc6845_cursor cursor;
341   int char_width;
342   const device_config *screen = video_screen_first(Machine->config);
343   int screen_width = video_screen_get_width(screen);
399   MDRV_DEVICE_ADD( HERCULES_MC6845_NAME, MC6845)
400   MDRV_DEVICE_CONFIG( mc6845_hercules_intf )
344401
345   char_width = screen_width / 80;
402   MDRV_VIDEO_START( pc_hercules )
403   MDRV_VIDEO_UPDATE( mc6845_hercules )
404MACHINE_DRIVER_END
346405
347   mscrtc6845_time(crtc);
348   mscrtc6845_get_cursor(crtc, &cursor);
349406
350   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
407static VIDEO_START( pc_hercules ) {
408   int buswidth;
409
410   buswidth = cputype_databus_width(machine->config->cpu[0].type, ADDRESS_SPACE_PROGRAM);
411   switch(buswidth)
351412   {
352      for (sx=0, r.min_x=0, r.max_x = char_width-1; sx<columns;
353          sx++, offs=(offs+2)&0x3fff, r.min_x += char_width, r.max_x += char_width)
354      {
355         int attr = videoram[offs+1];
356         if (attr & 0x80)   /* blinking ? */
357         {
358            if (mda.pc_blink) attr = 0;
359         }
413   case 8:
414      memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xbffff, 0, 0, SMH_BANK11 );
415      memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xbffff, 0, 0, pc_video_videoram_w );
416      memory_install_read8_handler(0, ADDRESS_SPACE_IO, 0x3b0, 0x3bf, 0, 0, pc_hercules_r );
417      memory_install_write8_handler(0, ADDRESS_SPACE_IO, 0x3b0, 0x3bf, 0, 0, pc_hercules_w );
418      break;
360419
361         drawgfx(bitmap, mda.gfx_char[CGA_FONT], videoram[offs], attr,
362               0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0);
363         /* Underlining */
364         if ((attr & 7) == 1)
365            plot_box(bitmap, r.min_x, r.min_y + 12, char_width,
366               1, Machine->pens[2 + (attr & 8)]);
420   default:
421      fatalerror("Hercules:  Bus width %d not supported\n", buswidth);
422      break;
423   }
367424
368//            if ((cursor.on)&&(offs==cursor.pos*2)) {
369         if (cursor.on&&(mda.pc_framecnt&32)&&(offs==cursor.pos*2)) {
370            int k=height-cursor.top;
371            rectangle rect2=r;
372            rect2.min_y+=cursor.top;
373            if (cursor.bottom<height) k=cursor.bottom-cursor.top+1;
425   memset( &mda, 0, sizeof(mda));
426   mda.update_row = NULL;
427   mda.chr_gen = memory_region( REGION_GFX1 );
374428
375            if (k>0)
376               plot_box(bitmap, r.min_x,
377                      r.min_y+cursor.top,
378                      char_width, k, Machine->pens[2/*?*/]);
379         }
380      }
381   }
429   videoram_size = 0x10000;
430   videoram = auto_malloc(videoram_size);
431   memory_set_bankptr(11, videoram);
382432}
383433
434
384435/***************************************************************************
385  Draw graphics with 720x384 pixels (default); so called Hercules gfx.
436  Draw graphics with 720x348 pixels (default); so called Hercules gfx.
386437  The memory layout is divided into 4 banks where of size 0x2000.
387438  Every bank holds data for every n'th scanline, 8 pixels per byte,
388439  bit 7 being the leftmost.
389440***************************************************************************/
390441
391static void hercules_gfx(bitmap_t *bitmap, struct mscrtc6845 *crtc)
392{
393   const UINT8 *vram = videoram;
394   static const UINT16 palette[2] = {0, 10};
442static MC6845_UPDATE_ROW( hercules_gfx_update_row ) {
443   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
444   UINT16   gfx_base = ( ( mda.mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( y & 0x03 ) << 13 );
445   int i;
395446
396   if (mda.mode_control & 0x80)
397      vram += 0x8000;
447   if ( y == 0 ) logerror("hercules_gfx_update_row\n");
448   for ( i = 0; i < x_count; i++ ) {
449      UINT8   data = videoram[ gfx_base + ( ( ma + i ) << 1 ) ];
398450
399   pc_render_gfx_1bpp(bitmap, crtc, vram, palette, 4);
451      *p = ( data & 0x80 ) ? 2 : 0; p++;
452      *p = ( data & 0x40 ) ? 2 : 0; p++;
453      *p = ( data & 0x20 ) ? 2 : 0; p++;
454      *p = ( data & 0x10 ) ? 2 : 0; p++;
455      *p = ( data & 0x08 ) ? 2 : 0; p++;
456      *p = ( data & 0x04 ) ? 2 : 0; p++;
457      *p = ( data & 0x02 ) ? 2 : 0; p++;
458      *p = ( data & 0x01 ) ? 2 : 0; p++;
459
460      data = videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ];
461
462      *p = ( data & 0x80 ) ? 2 : 0; p++;
463      *p = ( data & 0x40 ) ? 2 : 0; p++;
464      *p = ( data & 0x20 ) ? 2 : 0; p++;
465      *p = ( data & 0x10 ) ? 2 : 0; p++;
466      *p = ( data & 0x08 ) ? 2 : 0; p++;
467      *p = ( data & 0x04 ) ? 2 : 0; p++;
468      *p = ( data & 0x02 ) ? 2 : 0; p++;
469      *p = ( data & 0x01 ) ? 2 : 0; p++;
470   }
400471}
401472
402473
474static VIDEO_UPDATE( mc6845_hercules ) {
475   device_config   *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
476   mc6845_update( devconf, bitmap, cliprect );
477   return 0;
478}
403479
404/***************************************************************************
405  Choose the appropriate video mode
406***************************************************************************/
407480
408pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
409{
410   pc_video_update_proc proc = NULL;
411   const device_config *screen = video_screen_first(Machine->config);
412   int screen_width = video_screen_get_width(screen);
481static void hercules_mode_control_w(int data) {
482   MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
483      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
484   mda.mode_control = data;
413485
414   switch (mda.mode_control & 0x2a) { /* text and gfx modes */
486   switch( mda.mode_control & 0x2a ) {
415487   case 0x08:
416      proc = mda_text_inten;
417      *width *= screen_width / 80;
488      mda.update_row = mda_text_inten_update_row;
418489      break;
419490   case 0x28:
420      proc = mda_text_blink;
421      *width *= screen_width / 80;
491      mda.update_row = mda_text_blink_update_row;
422492      break;
423   case 0x0a:
424   case 0x2a:
425      proc = hercules_gfx;
426      *width *= 16;
493   case 0x0A:          /* Hercules modes */
494   case 0x2A:
495      mda.update_row = hercules_gfx_update_row;
427496      break;
428    }
429   return proc;
497   default:
498      mda.update_row = NULL;
499   }
430500}
431501
502
503static void hercules_config_w(int data)
504{
505   MDA_LOG(1,"HGC_config_w",("$%02x\n", data));
506   mda.configuration_switch = data;
507}
508
509
510static WRITE8_HANDLER ( pc_hercules_w ) {
511   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
512
513   switch( offset ) {
514   case 0: case 2: case 4: case 6:
515      mc6845_address_w( devconf, offset, data );
516      break;
517   case 1: case 3: case 5: case 7:
518      mc6845_register_w( devconf, offset, data );
519      break;
520   case 8:
521      hercules_mode_control_w(data);
522      break;
523   case 15:
524      hercules_config_w(data);
525      break;
526   }
527}
528
529
530/*  R-  CRT status register (see #P139)
531 *      (EGA/VGA) input status 1 register
532 *      7    HGC vertical sync in progress
533 *      6-4  adapter 000  hercules
534 *                   001  hercules+
535 *                   101  hercules InColor
536 *                   else unknown
537 *      3    pixel stream (0 black, 1 white)
538 *      2-1  reserved
539 *      0    horizontal drive enable
540 */
541static int pc_hercules_status_r(void)
542{
543   int data = mda.vsync | 0x08 | mda.hsync;
544   return data;
545}
546
547
548static READ8_HANDLER ( pc_hercules_r ) {
549   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
550   int data = 0xff;
551
552   switch( offset ) {
553   case 0: case 2: case 4: case 6:
554      /* return last written mc6845 address value here? */
555      break;
556   case 1: case 3: case 5: case 7:
557      data = mc6845_register_r( devconf, offset );
558      break;
559   case 10:
560      data = pc_hercules_status_r();
561      break;
562      /* 12, 13, 14  are the LPT1 ports */
563   }
564   return data;
565}
566
src/mess/video/pc_mda.h
r2058r2059
1#include "video/pc_video.h"
1/*
2  MDA vidoe card
3 */
4#define MDA_SCREEN_NAME   "mda_screen"
5#define MDA_MC6845_NAME   "mc6845_mda"
26
3#if 0
4   // cutted from some aga char rom
5   // 256 9x14 in 8x16 chars, line 3 is connected to a10
6    ROM_LOAD("mda.chr",     0x00000, 0x01000, CRC(ac1686f3))
7#endif
7MACHINE_DRIVER_EXTERN( pcvideo_mda );
88
9void pc_mda_init_video(void);
10void pc_mda_europc_init(void);
119
12void pc_mda_timer(void);
10/*
11  Hercules video card
12 */
13#define HERCULES_SCREEN_NAME "hercules_screen"
14#define HERCULES_MC6845_NAME "mc6845_hercules"
1315
14VIDEO_START ( pc_mda );
15pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
16MACHINE_DRIVER_EXTERN( pcvideo_hercules );
1617
17WRITE8_HANDLER ( pc_MDA_w );
18READ8_HANDLER ( pc_MDA_r );
19
20extern const unsigned char mda_palette[4][3];
21extern const gfx_layout pc_mda_charlayout;
22GFXDECODE_EXTERN( pc_mda );
23extern const unsigned short mda_colortable[256*2+1*2];
24
25PALETTE_INIT( pc_mda );
26
27//internal use
28void pc_mda_cursor(struct mscrtc6845_cursor *cursor);
src/mess/drivers/pc.c
r2058r2059
11851185   MDRV_MACHINE_RESET(pc_mda)
11861186
11871187   /* video hardware */
1188   MDRV_SCREEN_ADD("main", RASTER)
1189   MDRV_SCREEN_REFRESH_RATE(50)
1190   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
1191   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1192   MDRV_SCREEN_SIZE(80*9, 25*14)
1193   MDRV_SCREEN_VISIBLE_AREA(0,80*9-1, 0,25*14-1)
1194   MDRV_GFXDECODE(pc_mda)
1195   MDRV_PALETTE_LENGTH(sizeof(cga_palette) / sizeof(cga_palette[0]))
1196   MDRV_PALETTE_INIT(pc_mda)
1188   MDRV_IMPORT_FROM( pcvideo_mda )
11971189
1198   MDRV_VIDEO_START(pc_mda)
1199   MDRV_VIDEO_UPDATE(pc_video)
1200
12011190    /* sound hardware */
12021191   MDRV_SPEAKER_STANDARD_MONO("mono")
12031192   MDRV_SOUND_ADD(CUSTOM, 0)
r2058r2059
12171206MACHINE_DRIVER_END
12181207
12191208
1209static MACHINE_DRIVER_START( pcherc )
1210   /* basic machine hardware */
1211   MDRV_CPU_ADD_TAG("main", V20, 4772720)
1212   MDRV_CPU_PROGRAM_MAP(pc8_map, 0)
1213   MDRV_CPU_IO_MAP(pc8_io, 0)
1214   MDRV_CPU_VBLANK_INT_HACK(pc_mda_frame_interrupt, 4)
1215
1216   MDRV_MACHINE_RESET(pc_mda)
1217
1218   /* video hardware */
1219   MDRV_IMPORT_FROM( pcvideo_hercules )
1220
1221   /* sound hardware */
1222   MDRV_SPEAKER_STANDARD_MONO("mono")
1223   MDRV_SOUND_ADD(CUSTOM, 0)
1224   MDRV_SOUND_CONFIG(pc_sound_interface)
1225   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
1226#ifdef ADLIB
1227   MDRV_SOUND_ADD(YM3812, ym3812_StdClock)
1228   MDRV_SOUND_CONFIG(ym3812_interface)
1229   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
1230#endif
1231#ifdef GAMEBLASTER
1232   MDRV_SOUND_ADD(SAA1099, 4772720)
1233   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1234   MDRV_SOUND_ADD(SAA1099, 4772720)
1235   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1236#endif
1237MACHINE_DRIVER_END
1238
12201239static MACHINE_DRIVER_START( pccga )
12211240   /* basic machine hardware */
12221241   MDRV_CPU_PC(pc8, pc8, I8088, 4772720, pc_cga_frame_interrupt)   /* 4,77 Mhz */
r2058r2059
15371556    ROM_LOAD("mda.rom",     0x00000, 0x02000, CRC(0bf56d70) SHA1(c2a8b10808bf51a3c123ba3eb1e9dd608231916f)) // taken from original IBM MDA
15381557ROM_END
15391558
1559ROM_START( pcherc )
1560   ROM_REGION(0x100000,REGION_CPU1, 0)
1561   ROM_LOAD("wdbios.rom",  0xc8000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a))
1562   ROM_LOAD("pcxt.rom",    0xfe000, 0x02000, CRC(031aafad) SHA1(a641b505bbac97b8775f91fe9b83d9afdf4d038f))
1563   ROM_REGION(0x1000,REGION_GFX1, 0)
1564   ROM_LOAD("um2301.bin",  0x00000, 0x1000, CRC(0827bdac) SHA1(15f1aceeee8b31f0d860ff420643e3c7f29b5ffc))
1565ROM_END
1566
1567
15401568ROM_START( pc )
15411569    ROM_REGION(0x100000,REGION_CPU1, 0)
15421570    ROM_LOAD("wdbios.rom",  0xc8000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a))
r2058r2059
18521880COMP( 1987,   pc1640,      ibmpc,   0,      pc1640,     pc1640,      pc1640,      ibmpc,   "Amstrad plc",  "Amstrad PC1640 / PC6400 (US)", GAME_NOT_WORKING )
18531881// pc2086 pc1512 with vga??
18541882COMP ( 1987,   pcmda,      ibmpc,   0,      pcmda,      pcmda,      pcmda,       ibmpc,   "",  "PC (MDA)" , 0)
1883COMP ( 1987,    pcherc,     ibmpc,  0,      pcherc,     pcmda,      pcmda,      ibmpc,   "MESS",  "PC (Hercules)" , 0)
18551884COMP ( 1987,   xtvga,      ibmpc,   0,      xtvga,      xtvga,      pc_vga,     ibmpc,   "",  "PC/XT (VGA, MF2 Keyboard)" , 0)
18561885

Previous 15994 Revisions Next


© 1998-2018 The MESS Team