Previous 15994 Revisions Next

r2550 Monday 5th May, 2008 at 18:19:48 UTC by Wilbert Pol
[PC MDA/HERCULES] Fixed cursor blinking. Updated styling.
[src/mess/video]pc_mda.c

src/mess/video/pc_mda.c
r2549r2550
1616#define MDA_LOG(N,M,A) \
1717   if(VERBOSE_MDA>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; }
1818
19const unsigned char mda_palette[4][3] = {
19const unsigned char mda_palette[4][3] =
20{
2021   { 0x00,0x00,0x00 },
2122   { 0x00,0x55,0x00 },
2223   { 0x00,0xaa,0x00 },
2324   { 0x00,0xff,0x00 }
2425};
2526
26static struct {
27static struct
28{
2729   UINT8 status;
2830
2931   int pc_framecnt;
r2549r2550
5456static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed );
5557static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed );
5658
57static const mc6845_interface mc6845_mda_intf = {
59static const mc6845_interface mc6845_mda_intf =
60{
5861   MDA_SCREEN_NAME,   /* screen number */
5962   MDA_CLOCK/9 /*?*/,   /* clock */
6063   9,               /* number of pixels per video memory address */
r2549r2550
117120}
118121
119122
120static VIDEO_UPDATE( mc6845_mda ) {
123static VIDEO_UPDATE( mc6845_mda )
124{
121125   device_config   *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, MDA_MC6845_NAME);
122126   mc6845_update( devconf, bitmap, cliprect );
123127   return 0;
r2549r2550
130134  character codes 176 to 223.
131135***************************************************************************/
132136
133static MC6845_UPDATE_ROW( mda_text_inten_update_row ) {
137static MC6845_UPDATE_ROW( mda_text_inten_update_row )
138{
134139   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
135140   UINT16   chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra;
136141   int i;
137142
138143   if ( y == 0 ) MDA_LOG(1,"mda_text_inten_update_row",("\n"));
139   for ( i = 0; i < x_count; i++ ) {
144   for ( i = 0; i < x_count; i++ )
145   {
140146      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
141147      UINT8 chr = videoram[ offset ];
142148      UINT8 attr = videoram[ offset + 1 ];
r2549r2550
144150      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
145151      UINT8 bg = 0;
146152
147      if ( ( attr & ~0x88 ) == 0 ) {
153      if ( ( attr & ~0x88 ) == 0 )
154      {
148155         data = 0x00;
149156      }
150157
151      switch( attr ) {
158      switch( attr )
159      {
152160      case 0x70:
153161         bg = 2;
154162         fg = 0;
r2549r2550
167175         break;
168176      }
169177
170      if ( i == cursor_x || ( attr & 0x07 ) == 0x01 ) {
178      if ( ( i == cursor_x && ( mda.pc_framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 )
179      {
171180         data = 0xFF;
172181      }
173182
r2549r2550
179188      *p = ( data & 0x04 ) ? fg : bg; p++;
180189      *p = ( data & 0x02 ) ? fg : bg; p++;
181190      *p = ( data & 0x01 ) ? fg : bg; p++;
182      if ( ( chr & 0xE0 ) == 0xC0 ) {
191      if ( ( chr & 0xE0 ) == 0xC0 )
192      {
183193         *p = ( data & 0x01 ) ? fg : bg; p++;
184      } else {
194      }
195      else
196      {
185197         *p = bg; p++;
186198      }
187199   }
r2549r2550
194206  character codes 176 to 223.
195207***************************************************************************/
196208
197static MC6845_UPDATE_ROW( mda_text_blink_update_row ) {
209static MC6845_UPDATE_ROW( mda_text_blink_update_row )
210{
198211   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
199212   UINT16   chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra;
200213   int i;
201214
202215   if ( y == 0 ) MDA_LOG(1,"mda_text_blink_update_row",("\n"));
203   for ( i = 0; i < x_count; i++ ) {
216   for ( i = 0; i < x_count; i++ )
217   {
204218      UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF;
205219      UINT8 chr = videoram[ offset ];
206220      UINT8 attr = videoram[ offset + 1 ];
r2549r2550
208222      UINT8 fg = ( attr & 0x08 ) ? 3 : 2;
209223      UINT8 bg = 0;
210224
211      if ( ( attr & ~0x88 ) == 0 ) {
225      if ( ( attr & ~0x88 ) == 0 )
226      {
212227         data = 0x00;
213228      }
214229
215      switch( attr ) {
230      switch( attr )
231      {
216232      case 0x70:
217233      case 0xF0:
218234         bg = 2;
r2549r2550
225241         break;
226242      }
227243
228      if ( i == cursor_x ) {
244      if ( ( attr & 0x07 ) == 0x01 )
245      {
229246         data = 0xFF;
230      } else {
231         if ( ( attr & 0x07 ) == 0x01 ) {
247      }
248
249      if ( i == cursor_x )
250      {
251         if ( mda.pc_framecnt & 0x08 )
252         {
232253            data = 0xFF;
233254         }
234         if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x40 ) ) {
255      }
256      else
257      {
258         if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x10 ) )
259         {
235260            data = 0x00;
236261         }
237262      }
r2549r2550
244269      *p = ( data & 0x04 ) ? fg : bg; p++;
245270      *p = ( data & 0x02 ) ? fg : bg; p++;
246271      *p = ( data & 0x01 ) ? fg : bg; p++;
247      if ( ( chr & 0xE0 ) == 0xC0 ) {
272      if ( ( chr & 0xE0 ) == 0xC0 )
273      {
248274         *p = ( data & 0x01 ) ? fg : bg; p++;
249      } else {
275      }
276      else
277      {
250278         *p = bg; p++;
251279      }
252280   }
253281}
254282
255283
256static MC6845_UPDATE_ROW( mda_update_row ) {
257   if ( mda.update_row ) {
284static MC6845_UPDATE_ROW( mda_update_row )
285{
286   if ( mda.update_row )
287   {
258288      mda.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
259289   }
260290}
261291
262292
263static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed ) {
293static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed )
294{
264295   mda.hsync = hsync ? 1 : 0;
265296}
266297
267298
268static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed ) {
299static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed )
300{
269301   mda.vsync = vsync ? 0x80 : 0;
270   if ( vsync ) {
302   if ( vsync )
303   {
271304      mda.pc_framecnt++;
272305   }
273306}
r2549r2550
282315      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
283316   mda.mode_control = data;
284317
285   switch( mda.mode_control & 0x2a ) {
318   switch( mda.mode_control & 0x2a )
319   {
286320   case 0x08:
287321      mda.update_row = mda_text_inten_update_row;
288322      break;
r2549r2550
377411The divder/pixels per 6845 clock is 9 for text mode and 16 for graphics mode.
378412*/
379413
380static const mc6845_interface mc6845_hercules_intf = {
414static const mc6845_interface mc6845_hercules_intf =
415{
381416   HERCULES_SCREEN_NAME,   /* screen number */
382417   MDA_CLOCK/9 /*?*/,      /* clock */
383418   9,                  /* number of pixels per video memory address */
r2549r2550
405440MACHINE_DRIVER_END
406441
407442
408static VIDEO_START( pc_hercules ) {
443static VIDEO_START( pc_hercules )
444{
409445   int buswidth;
410446
411447   buswidth = cputype_databus_width(machine->config->cpu[0].type, ADDRESS_SPACE_PROGRAM);
r2549r2550
440476  bit 7 being the leftmost.
441477***************************************************************************/
442478
443static MC6845_UPDATE_ROW( hercules_gfx_update_row ) {
479static MC6845_UPDATE_ROW( hercules_gfx_update_row )
480{
444481   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
445482   UINT16   gfx_base = ( ( mda.mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 );
446483   int i;
447484
448485   if ( y == 0 ) MDA_LOG(1,"hercules_gfx_update_row",("\n"));
449   for ( i = 0; i < x_count; i++ ) {
486   for ( i = 0; i < x_count; i++ )
487   {
450488      UINT8   data = videoram[ gfx_base + ( ( ma + i ) << 1 ) ];
451489
452490      *p = ( data & 0x80 ) ? 2 : 0; p++;
r2549r2550
472510}
473511
474512
475static VIDEO_UPDATE( mc6845_hercules ) {
513static VIDEO_UPDATE( mc6845_hercules )
514{
476515   device_config   *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
477516   mc6845_update( devconf, bitmap, cliprect );
478517   return 0;
479518}
480519
481520
482static void hercules_mode_control_w(running_machine *machine, int data) {
521static void hercules_mode_control_w(running_machine *machine, int data)
522{
483523   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
484524
485525   MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n",
486526      data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1));
487527   mda.mode_control = data;
488528
489   switch( mda.mode_control & 0x2a ) {
529   switch( mda.mode_control & 0x2a )
530   {
490531   case 0x08:
491532      mda.update_row = mda_text_inten_update_row;
492533      break;
r2549r2550
513554}
514555
515556
516static WRITE8_HANDLER ( pc_hercules_w ) {
557static WRITE8_HANDLER ( pc_hercules_w )
558{
517559   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
518560
519   switch( offset ) {
561   switch( offset )
562   {
520563   case 0: case 2: case 4: case 6:
521564      mc6845_address_w( devconf, offset, data );
522565      break;
r2549r2550
551594}
552595
553596
554static READ8_HANDLER ( pc_hercules_r ) {
597static READ8_HANDLER ( pc_hercules_r )
598{
555599   device_config   *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME);
556600   int data = 0xff;
557601
558   switch( offset ) {
602   switch( offset )
603   {
559604   case 0: case 2: case 4: case 6:
560605      /* return last written mc6845 address value here? */
561606      break;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team