Previous 15994 Revisions Next

r2704 Friday 23rd May, 2008 at 19:57:11 UTC by Wilbert Pol
[PC_EGA] Added some more documentation. Implemented some basic parts of the hardware.
[src/mess/video]pc_ega.c

src/mess/video/pc_ega.c
r2703r2704
44
55TODO - Write documentation
66
7The EGA graphics card introduced a lot of new indexed registers to handle the
7"Regular" register on an EGA graphics card:
8
9   3C2 - 7 6 5 4 3 2 1 0 - Misc Output Register - Write Only
10         | | | | | | | |
11         | | | | | | | +-- 3Bx/3Dx I/O port select
12         | | | | | | |     0 = 3Bx for CRTC I/O, 3BA for status reg 1
13         | | | | | | |     1 = 3Dx for CRTC I/O, 3DA for status reg 1
14         | | | | | | +---- enable ram
15         | | | | | |       0 = disable ram from the processor
16         | | | | | |       1 = enable ram to respond to addresses
17         | | | | | |           designated by the Control Data Select
18         | | | | | |           value in the Graphics Controllers.
19         | | | | | +------ clock select bit 0
20         | | | | +-------- clock select bit 1
21         | | | |           00 = 14Mhz from Processor I/O channel
22         | | | |           01 = 16MHz on-bord clock
23         | | | |           10 = External clock from feature connector
24         | | | |           11 = reserved/unused
25         | | | +---------- disable video drivers
26         | | |             0 = activate internal video drivers
27         | | |             1 = disable internal video drivers
28         | | +------------ page bit for odd/even. Selects between 2 pages
29         | |               of 64KB of memory when in odd/even mode.
30         | |               0 = select low page
31         | |               1 = select high page
32         | +-------------- horizontal retrace polarity
33         |                 0 = select positive
34         |                 1 = select negative
35         +---------------- vertical retrace polarity
36                           0 = select positive
37                           1 = select negative
38
39
40   3C2 - 7 6 5 4 3 2 1 0 - Input Status Reg 0 - Read Only
41         | | | | | | | |
42         | | | | | | | +-- reserved/unused
43         | | | | | | +---- reserved/unused
44         | | | | | +------ reserved/unused
45         | | | | +-------- reserved/unused
46         | | | +---------- switch sense
47         | | |             0 = switch is closed
48         | | |             1 = allows processor to read the 4 config switches
49         | | |                 on the EGA adapter. The setting of CLKSEL determines
50         | | |                 switch to read.
51         | | +------------ input from FEAT0 on the feature connector
52         | +-------------- input from FEAT1 on the feature connector
53         +---------------- CRT Interrupt
54                           0 = vertical retrace if occuring
55                           1 = video is being displayed
56
57
58   3XA - 7 6 5 4 3 2 1 0 - Feature Control Register - Write Only
59         | | | | | | | |
60         | | | | | | | +-- output to FEAT0 of the feature connector
61         | | | | | | +---- output to FEAT1 of the feature connector
62         | | | | | +------ reserved/unused
63         | | | | +-------- reserved/unused
64         | | | +---------- reserved/unused
65         | | +------------ reserved/unused
66         | +-------------- reserved/unused
67         +---------------- reserved/unused
68
69   3XA - 7 6 5 4 3 2 1 0 - Input Status Reg 1 - Read Only
70         | | | | | | | |
71         | | | | | | | +-- display enable
72         | | | | | | |     0 = indicates the CRT raster is in a horizontal or vertical retrace
73         | | | | | | |     1 = otherwise
74         | | | | | | +---- light pen strobe
75         | | | | | |       0 = light pen trigger has not been set
76         | | | | | |       1 = light pen trigger has been set
77         | | | | | +------ light pen switch
78         | | | | |         0 = switch is closed
79         | | | | |         1 = switch is open
80         | | | | +-------- vertical retrace
81         | | | |           0 = video information is being displayed
82         | | | |           1 = CRT is in vertical retrace
83         | | | +---------- diagnostic usage
84         | | +------------ diagnostic usage
85         | +-------------- reserved/unused
86         +---------------- reserved/unused
87
88
89The EGA graphics card introduces a lot of new indexed registers to handle the
890enhanced graphics. These new indexed registers can be divided into three
991groups:
1092- attribute registers
r2703r2704
1597Attribute Registers AR00 - AR13
1698
1799The Attribute Registers are all accessed through I/O port 0x3C0. The first
18write to I/O port 0x3C0 sets an auto-incrementing index register. Further
19writes to I/O port 0x3C0 actually set the data to the indexed register.
100write to I/O port 0x3C0 sets the index register. The next write to I/O port
1010x3C0 actually sets the data to the indexed register.
20102
21103   3C0 - 7 6 5 4 3 2 1 0 - Attribute Access Register
22104         | | | | | | | |
23         | | | | | | | +--
24         | | | | | | +----
25         | | | | | +------
26         | | | | +--------
27         | | | +----------
28         | | +------------
29         | +--------------
30         +----------------
105         | | | | | | | +-- index bit 0
106         | | | | | | +---- index bit 1
107         | | | | | +------ index bit 2
108         | | | | +-------- index bit 3
109         | | | +---------- index bit 4
110         | | +------------ palette source
111         | +-------------- reserved/unused
112         +---------------- reserved/unused
31113
32114
33115   AR00-AR0F - 7 6 5 4 3 2 1 0 - Palette Register #00 - #0F
r2703r2704
335417   const device_config   *mc6845;
336418   mc6845_update_row_func   update_row;
337419
420   /* Registers */
421   UINT8   misc_output;
422   UINT8   feature_control;
423
338424   /* Attribute registers AR00 - AR14
339425   */
340426   struct {
341427      UINT8   index;
342428      UINT8   data[32];
429      UINT8   index_write;
343430   } attribute;
344431
345432   /* Sequencer registers SR00 - SR04
r2703r2704
368455static MC6845_UPDATE_ROW( ega_update_row );
369456static MC6845_ON_HSYNC_CHANGED( ega_hsync_changed );
370457static MC6845_ON_VSYNC_CHANGED( ega_vsync_changed );
458static READ8_HANDLER( pc_ega8_3b0_r );
459static WRITE8_HANDLER( pc_ega8_3b0_w );
460static READ16_HANDLER( pc_ega16le_3b0_r );
461static WRITE16_HANDLER( pc_ega16le_3b0_w );
462static READ32_HANDLER( pc_ega32le_3b0_r );
463static WRITE32_HANDLER( pc_ega32le_3b0_w );
464static READ8_HANDLER( pc_ega8_3c0_r );
465static WRITE8_HANDLER( pc_ega8_3c0_w );
466static READ16_HANDLER( pc_ega16le_3c0_r );
467static WRITE16_HANDLER( pc_ega16le_3c0_w );
468static READ32_HANDLER( pc_ega32le_3c0_r );
469static WRITE32_HANDLER( pc_ega32le_3c0_w );
371470static READ8_HANDLER( pc_ega8_3d0_r );
372471static WRITE8_HANDLER( pc_ega8_3d0_w );
373472static READ16_HANDLER( pc_ega16le_3d0_r );
374473static WRITE16_HANDLER( pc_ega16le_3d0_w );
375474static READ32_HANDLER( pc_ega32le_3d0_r );
376475static WRITE32_HANDLER( pc_ega32le_3d0_w );
377static READ8_HANDLER( pc_ega8_3c0_r );
378static WRITE8_HANDLER( pc_ega8_3c0_w );
379static READ16_HANDLER( pc_ega16le_3c0_r );
380static WRITE16_HANDLER( pc_ega16le_3c0_w );
381static READ32_HANDLER( pc_ega32le_3c0_r );
382static WRITE32_HANDLER( pc_ega32le_3c0_w );
383476
384477
385478static const mc6845_interface mc6845_ega_intf =
r2703r2704
437530      case 8:
438531         memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, SMH_BANK11 );
439532         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, pc_video_videoram_w );
533         memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3b0, 0x3bb, 0, 0, pc_ega8_3b0_r );
534         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3b0, 0x3bb, 0, 0, pc_ega8_3b0_w );
535         memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega8_3c0_r );
536         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega8_3c0_w );
440537         memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3d0, 0x3db, 0, 0, pc_ega8_3d0_r );
441538         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3d0, 0x3db, 0, 0, pc_ega8_3d0_w );
442         memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega8_3c0_r );
443         memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega8_3c0_w );
444539         break;
445540
446541      case 16:
447542         memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, SMH_BANK11 );
448543         memory_install_write16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, pc_video_videoram16le_w );
544         memory_install_read16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3b0, 0x3bb, 0, 0, pc_ega16le_3b0_r );
545         memory_install_write16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3b0, 0x3bb, 0, 0, pc_ega16le_3b0_w );
546         memory_install_read16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega16le_3c0_r );
547         memory_install_write16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega16le_3c0_w );
449548         memory_install_read16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3d0, 0x3db, 0, 0, pc_ega16le_3d0_r );
450549         memory_install_write16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3d0, 0x3db, 0, 0, pc_ega16le_3d0_w );
451         memory_install_read16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega16le_3c0_r );
452         memory_install_write16_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega16le_3c0_w );
453550         break;
454551
455552      case 32:
456553         memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, SMH_BANK11 );
457554         memory_install_write32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, pc_video_videoram32_w );
555         memory_install_read32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3b0, 0x3bb, 0, 0, pc_ega32le_3b0_r );
556         memory_install_write32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3b0, 0x3bb, 0, 0, pc_ega32le_3b0_w );
557         memory_install_read32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega32le_3c0_r );
558         memory_install_write32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega32le_3c0_w );
458559         memory_install_read32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3d0, 0x3db, 0, 0, pc_ega32le_3d0_r );
459560         memory_install_write32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3d0, 0x3db, 0, 0, pc_ega32le_3d0_w );
460         memory_install_read32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega32le_3c0_r );
461         memory_install_write32_handler(machine, 0, ADDRESS_SPACE_IO, 0x3c0, 0x3cf, 0, 0, pc_ega32le_3c0_w );
462561         break;
463562
464563      default:
r2703r2704
475574
476575   ega.mc6845 = device_list_find_by_tag(machine->config->devicelist, MC6845, EGA_MC6845_NAME);
477576   ega.update_row = NULL;
577   ega.misc_output = 0;
578   ega.attribute.index_write = 1;
478579
479580   /* Set up default palette */
480581   ega.attribute.data[0] = 0;
r2703r2704
528629}
529630
530631
531static READ8_HANDLER( pc_ega8_3d0_r )
632static READ8_HANDLER( pc_ega8_3X0_r )
532633{
533634   int data = 0xff;
534635
535636   if ( VERBOSE_EGA )
536637   {
537      logerror("pc_ega_3b0_r: offset = %02x\n", offset );
638      logerror("pc_ega_3X0_r: offset = %02x\n", offset );
538639   }
539640
540641   switch ( offset )
r2703r2704
549650      data = mc6845_register_r( ega.mc6845, offset );
550651      break;
551652
552   /* Display status */
653   /* Input Status Register 1 */
553654   case 10:
554655      data = ega.vsync | ega.hsync;
656
657      /* Reset the attirubte writing flip flop to let the next write go to the index reigster */
658      ega.attribute.index_write = 1;
555659      break;
556660   }
557661
r2703r2704
559663}
560664
561665
562static WRITE8_HANDLER( pc_ega8_3d0_w )
666static WRITE8_HANDLER( pc_ega8_3X0_w )
563667{
564668   if ( VERBOSE_EGA )
565669   {
566      logerror("pc_ega_3b0_w: offset = %02x, data = %02x\n", offset, data );
670      logerror("pc_ega_3X0_w: offset = %02x, data = %02x\n", offset, data );
567671   }
568672
569673   switch ( offset )
r2703r2704
584688
585689   /* Feature Control */
586690   case 10:
691      ega.feature_control = data;
587692      break;
588693
589694   /* Clear Light Pen Flip Flop */
r2703r2704
593698}
594699
595700
701static READ8_HANDLER( pc_ega8_3b0_r )
702{
703   return ( ega.misc_output & 0x01 ) ? 0xFF : pc_ega8_3X0_r( machine, offset );
704}
705
706
707static READ8_HANDLER( pc_ega8_3d0_r )
708{
709   return ( ega.misc_output & 0x01 ) ? pc_ega8_3X0_r( machine, offset ) : 0xFF;
710}
711
712
713static WRITE8_HANDLER( pc_ega8_3b0_w )
714{
715   if ( ! ( ega.misc_output & 0x01 ) )
716   {
717      pc_ega8_3X0_w( machine, offset, data );
718   }
719}
720
721
722static WRITE8_HANDLER( pc_ega8_3d0_w )
723{
724   if ( ega.misc_output & 0x01 )
725   {
726      pc_ega8_3X0_w( machine, offset, data );
727   }
728}
729
730
596731static READ8_HANDLER( pc_ega8_3c0_r )
597732{
598733   int data = 0xff;
r2703r2704
606741   {
607742   /* Attributes Controller */
608743   case 0:
609      data = ega.attribute.index;
610744      break;
611   case 1:
612      if ( ( ega.attribute.index & 0x30 ) != 0x20 )
613      {
614         data = ega.attribute.data[ ega.attribute.index & 0x1F ];
615      }
616      break;
617745
618746   /* Feature Read */
619747   case 2:
748      data = ( data & 0x0F );
749      data |= ( ( ega.feature_control & 0x03 ) << 5 );
750      data |= ( ega.vsync ? 0x00 : 0x80 );
620751      break;
621752
622753   /* Sequencer */
623754   case 4:
624      data = ega.sequencer.index;
625755      break;
626756   case 5:
627      data = ega.sequencer.data[ ega.sequencer.index & 0x07 ];
628757      break;
629758
630759   /* Graphics Controller */
631760   case 14:
632      data = ega.graphics_controller.index;
633761      break;
634762   case 15:
635      data = ega.graphics_controller.data[ ega.graphics_controller.index & 0x0F];
636763      break;
637764   }
638765   return data;
r2703r2704
650777   {
651778   /* Attributes Controller */
652779   case 0:
653      ega.attribute.index = data;
654      break;
655   case 1:
656      if ( ( ega.attribute.index & 0x30 ) != 0x20 )
780      if ( ega.attribute.index_write )
657781      {
658//logerror("AR%02x = 0x%02x\n", ega.attribute.index & 0x1F, data );
782         ega.attribute.index = data;
783      }
784      else
785      {
659786         ega.attribute.data[ ega.attribute.index & 0x1F ] = data;
660787      }
788      ega.attribute.index_write ^= 0x01;
661789      break;
662790
663791   /* Misccellaneous Output */
664792   case 2:
793      ega.misc_output = data;
665794      break;
666795
667796   /* Sequencer */
r2703r2704
684813   }
685814}
686815
687static READ16_HANDLER( pc_ega16le_3d0_r ) { return read16le_with_read8_handler(pc_ega8_3d0_r,machine,  offset, mem_mask); }
688static WRITE16_HANDLER( pc_ega16le_3d0_w ) { write16le_with_write8_handler(pc_ega8_3d0_w, machine, offset, data, mem_mask); }
689static READ32_HANDLER( pc_ega32le_3d0_r ) { return read32le_with_read8_handler(pc_ega8_3d0_r, machine, offset, mem_mask); }
690static WRITE32_HANDLER( pc_ega32le_3d0_w ) { write32le_with_write8_handler(pc_ega8_3d0_w, machine, offset, data, mem_mask); }
816static READ16_HANDLER( pc_ega16le_3b0_r ) { return read16le_with_read8_handler(pc_ega8_3b0_r,machine,  offset, mem_mask); }
817static WRITE16_HANDLER( pc_ega16le_3b0_w ) { write16le_with_write8_handler(pc_ega8_3b0_w, machine, offset, data, mem_mask); }
818static READ32_HANDLER( pc_ega32le_3b0_r ) { return read32le_with_read8_handler(pc_ega8_3b0_r, machine, offset, mem_mask); }
819static WRITE32_HANDLER( pc_ega32le_3b0_w ) { write32le_with_write8_handler(pc_ega8_3b0_w, machine, offset, data, mem_mask); }
691820
692821static READ16_HANDLER( pc_ega16le_3c0_r ) { return read16le_with_read8_handler(pc_ega8_3c0_r,machine,  offset, mem_mask); }
693822static WRITE16_HANDLER( pc_ega16le_3c0_w ) { write16le_with_write8_handler(pc_ega8_3c0_w, machine, offset, data, mem_mask); }
694823static READ32_HANDLER( pc_ega32le_3c0_r ) { return read32le_with_read8_handler(pc_ega8_3c0_r, machine, offset, mem_mask); }
695824static WRITE32_HANDLER( pc_ega32le_3c0_w ) { write32le_with_write8_handler(pc_ega8_3c0_w, machine, offset, data, mem_mask); }
696825
826static READ16_HANDLER( pc_ega16le_3d0_r ) { return read16le_with_read8_handler(pc_ega8_3d0_r,machine,  offset, mem_mask); }
827static WRITE16_HANDLER( pc_ega16le_3d0_w ) { write16le_with_write8_handler(pc_ega8_3d0_w, machine, offset, data, mem_mask); }
828static READ32_HANDLER( pc_ega32le_3d0_r ) { return read32le_with_read8_handler(pc_ega8_3d0_r, machine, offset, mem_mask); }
829static WRITE32_HANDLER( pc_ega32le_3d0_w ) { write32le_with_write8_handler(pc_ega8_3d0_w, machine, offset, data, mem_mask); }
830

Previous 15994 Revisions Next


© 1998-2018 The MESS Team