Previous 199869 Revisions Next

r22818 Tuesday 14th May, 2013 at 08:09:30 UTC by Barry Rodewald
vga: made VGA offset calculation an overridable method, instead of a macro.  Fixes display in XF86_S3.  Added a little bit to svga_dm, but still needs a lot of work.
[src/emu/video]pc_vga.c pc_vga.h

trunk/src/emu/video/pc_vga.c
r22817r22818
8080#define VGA_START_ADDRESS (vga.crtc.start_addr)
8181#define VGA_LINE_LENGTH (vga.crtc.offset<<3)
8282
83#define IBM8514_LINE_LENGTH (m_vga->vga.crtc.offset << 3)
83#define IBM8514_LINE_LENGTH (m_vga->offset())
8484
8585#define CHAR_WIDTH ((vga.sequencer.data[1]&1)?8:9)
8686
r22817r22818
254254
255255   // copy over interfaces
256256   vga.read_dipswitch = read8_delegate(); //read_dipswitch;
257   vga.svga_intf.seq_regcount = 0x08;
258   vga.svga_intf.crtc_regcount = 0x19;
257   vga.svga_intf.seq_regcount = 0x1f;
258   vga.svga_intf.crtc_regcount = 0x2d;
259259   vga.svga_intf.vram_size = 0x200000;
260260
261261   vga.memory  = auto_alloc_array_clear(machine(), UINT8, vga.svga_intf.vram_size);
r22817r22818
289289   // set device ID
290290   s3.id_high = 0x88;  // CR2D
291291   s3.id_low = 0x11;   // CR2E
292   s3.revision = 0x00; // CR2F
293   s3.id_cr30 = 0xc0;  // CR30
292   s3.revision = 0x40; // CR2F
293   s3.id_cr30 = 0xe0;  // CR30
294294}
295295
296296void tseng_vga_device::device_start()
r22817r22818
320320   memset(&mach8, 0, sizeof(mach8));
321321}
322322
323UINT16 vga_device::offset()
324{
325//   popmessage("Offset: %04x  %s %s **",vga.crtc.offset,vga.crtc.dw?"DW":"--",vga.crtc.word_mode?"BYTE":"WORD");
326   if(vga.crtc.dw)
327      return vga.crtc.offset << 3;
328   if(vga.crtc.word_mode)
329      return vga.crtc.offset << 1;
330   else
331      return vga.crtc.offset << 2;
332}
333
323334void vga_device::vga_vh_text(bitmap_rgb32 &bitmap, const rectangle &cliprect)
324335{
325336   UINT8 ch, attr;
r22817r22818
337348      vga.cursor.visible = 0;
338349
339350   for (addr = vga.crtc.start_addr, line = -vga.crtc.preset_row_scan; line < TEXT_LINES;
340         line += height, addr += TEXT_LINE_LENGTH)
351         line += height, addr += (offset()>>1))
341352   {
342353      for (pos = addr, column=0; column<TEXT_COLUMNS; column++, pos++)
343354      {
r22817r22818
408419
409420   /**/
410421   for (addr=EGA_START_ADDRESS, pos=0, line=0; line<LINES;
411         line += height, addr += EGA_LINE_LENGTH)
422         line += height, addr += offset())
412423   {
413424      for(yi=0;yi<height;yi++)
414425      {
r22817r22818
460471   curr_addr = 0;
461472   if(!(vga.sequencer.data[4] & 0x08))
462473   {
463      for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=VGA_LINE_LENGTH/4, curr_addr+=VGA_LINE_LENGTH/4)
474      for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=offset(), curr_addr+=offset())
464475      {
465476         for(yi = 0;yi < height; yi++)
466477         {
r22817r22818
486497   }
487498   else
488499   {
489      for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=VGA_LINE_LENGTH, curr_addr+=VGA_LINE_LENGTH)
500      for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=offset(), curr_addr+=offset())
490501      {
491502         for(yi = 0;yi < height; yi++)
492503         {
r22817r22818
592603   int yi;
593604   int xi;
594605   UINT8 start_shift;
595   UINT16 line_length;
606//   UINT16 line_length;
596607
597608   /* line compare is screen sensitive */
598609   mask_comp = 0x3ff;
599610   curr_addr = 0;
600611
601   if(vga.crtc.dw)
602      line_length = vga.crtc.offset << 3;  // doubleword mode
603   else
604   {
605      line_length = vga.crtc.offset << 4;
606   }
612//   if(vga.crtc.dw)
613//      line_length = vga.crtc.offset << 3;  // doubleword mode
614//   else
615//   {
616//      line_length = vga.crtc.offset << 4;
617//   }
607618
608619   start_shift = (!(vga.sequencer.data[4] & 0x08)) ? 2 : 0;
609620
610621   {
611      for (addr = VGA_START_ADDRESS << start_shift, line=0; line<LINES; line+=height, addr+=line_length, curr_addr+=line_length)
622      for (addr = VGA_START_ADDRESS << start_shift, line=0; line<LINES; line+=height, addr+=offset(), curr_addr+=offset())
612623      {
613624         for(yi = 0;yi < height; yi++)
614625         {
r22817r22818
652663//  mask_comp = 0xff | (TLINES & 0x300);
653664   curr_addr = 0;
654665   yi=0;
655   for (addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=TGA_LINE_LENGTH, curr_addr+=TGA_LINE_LENGTH)
666   for (addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
656667   {
657668      bitmapline = &bitmap.pix32(line);
658669      addr %= vga.svga_intf.vram_size;
r22817r22818
696707//  mask_comp = 0xff | (TLINES & 0x300);
697708   curr_addr = 0;
698709   yi=0;
699   for (addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=TGA_LINE_LENGTH, curr_addr+=TGA_LINE_LENGTH)
710   for (addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
700711   {
701712      bitmapline = &bitmap.pix32(line);
702713      addr %= vga.svga_intf.vram_size;
r22817r22818
740751//  mask_comp = 0xff | (TLINES & 0x300);
741752   curr_addr = 0;
742753   yi=0;
743   for (addr = TGA_START_ADDRESS<<1, line=0; line<TLINES; line+=height, addr+=TGA_LINE_LENGTH, curr_addr+=TGA_LINE_LENGTH)
754   for (addr = TGA_START_ADDRESS<<1, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
744755   {
745756      bitmapline = &bitmap.pix32(line);
746757      addr %= vga.svga_intf.vram_size;
r22817r22818
781792//  mask_comp = 0xff | (TLINES & 0x300);
782793   curr_addr = 0;
783794   yi=0;
784   for (addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=(vga.crtc.offset * 4), curr_addr+=(vga.crtc.offset * 4))
795   for (addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=(offset()), curr_addr+=(offset()))
785796   {
786797      bitmapline = &bitmap.pix32(line);
787798      addr %= vga.svga_intf.vram_size;
r22817r22818
26592670
26602671******************************************/
26612672
2673UINT16 s3_vga_device::offset()
2674{
2675   //popmessage("Offset: %04x  %s %s %s",vga.crtc.offset,vga.crtc.dw?"DW":"--",vga.crtc.word_mode?"BYTE":"WORD",(s3.memory_config & 0x08)?"31":"--");
2676   if(s3.memory_config & 0x08)
2677      return vga.crtc.offset << 3;
2678   return vga_device::offset();
2679}
2680
26622681UINT8 s3_vga_device::s3_crtc_reg_read(UINT8 index)
26632682{
26642683   UINT8 res;
r22817r22818
27372756         case 0x51:
27382757            res = (vga.crtc.start_addr_latch & 0x0c0000) >> 18;
27392758            res |= ((svga.bank_w & 0x30) >> 2);
2759            res |= ((vga.crtc.offset & 0x0300) >> 4);
27402760            break;
27412761         case 0x55:
27422762            res = s3.extended_dac_ctrl;
r22817r22818
50505070   }
50515071}
50525072
5073UINT16 ati_vga_device::offset()
5074{
5075   //popmessage("Offset: %04x  %s %s %s %s",vga.crtc.offset,vga.crtc.dw?"DW":"--",vga.crtc.word_mode?"BYTE":"WORD",(ati.ext_reg[0x33] & 0x40) ? "PEL" : "---",(ati.ext_reg[0x30] & 0x20) ? "256" : "---");
5076   if(ati.ext_reg[0x30] & 0x20)  // likely wrong, gets 640x400/480 SVGA and tweaked 256 colour modes displaying correctly in Fractint.
5077      return vga_device::offset() << 3;
5078   if(ati.ext_reg[0x33] & 0x40)
5079      return vga_device::offset() << 2;
5080   return vga_device::offset();
5081}
50535082
5083
50545084void ati_vga_device::ati_define_video_mode()
50555085{
50565086   int clock;
r22817r22818
52245254         //logerror("ATI: Memory Page Select write %02x (read: %i write %i)\n",data,svga.bank_r,svga.bank_w);
52255255         break;
52265256      case 0x33:  // EEPROM
5257
52275258         if(data & 0x04)
52285259         {
52295260            eeprom_device* eep = subdevice<eeprom_device>("ati_eeprom");
r22817r22818
55765607   }
55775608}
55785609
5610UINT16 cirrus_vga_device::offset()
5611{
5612   //popmessage("Offset: %04x  %s %s **",vga.crtc.offset,vga.crtc.dw?"DW":"--",vga.crtc.word_mode?"BYTE":"WORD");
5613   if(gc_mode_ext & 0x10)
5614      return vga.crtc.offset << 3;
5615   return vga_device::offset();
5616}
5617
55795618UINT8 cirrus_vga_device::cirrus_seq_reg_read(UINT8 index)
55805619{
55815620   UINT8 res;
r22817r22818
55905629      {
55915630         case 0x06:
55925631         case 0x07:
5632         case 0x09:
5633         case 0x0a:
55935634            //printf("%02x\n",index);
55945635            res = vga.sequencer.data[index];
55955636            break;
r22817r22818
56125653      {
56135654         case 0x06:
56145655         case 0x07:
5656         case 0x09:
5657         case 0x0a:
56155658            //printf("%02x %02x\n",index,data);
56165659            vga.sequencer.data[vga.sequencer.index] = data;
56175660            break;
56185661      }
56195662   }
56205663}
5664
5665UINT8 cirrus_vga_device::cirrus_gc_reg_read(UINT8 index)
5666{
5667   UINT8 res = 0xff;
5668
5669   switch(index)
5670   {
5671   case 0x00:
5672      break;
5673   case 0x01:
5674      break;
5675   case 0x09:  // Offset register 0
5676      res = gc_bank_0;
5677      break;
5678   case 0x0a:  // Offset register 1
5679      res = gc_bank_1;
5680      break;
5681   case 0x0b:  // Graphics controller mode extensions
5682      res = gc_mode_ext;
5683      break;
5684   case 0x0c:  // Colour Key
5685      break;
5686   case 0x0d:  // Colour Key Mask
5687      break;
5688   case 0x0e:  // Miscellaneous Control
5689      break;
5690   case 0x10:  // Foreground Colour Byte 1
5691      break;
5692   case 0x11:  // Background Colour Byte 1
5693      break;
5694      // later registers are related to the BitBLT hardware
5695   default:
5696      res = gc_reg_read(index);
5697   }
5698
5699   return res;
5700}
5701
5702void cirrus_vga_device::cirrus_gc_reg_write(UINT8 index, UINT8 data)
5703{
5704   logerror("CL: GC write %02x to GR%02x\n",data,index);
5705   switch(index)
5706   {
5707   case 0x00:
5708   case 0x01:  // if extended writes are enabled (bit 2 of index 0bh), then index 0 and 1 are extended to 8 bits
5709      if(gc_mode_ext & 0x02)
5710         gc_reg_write(index,data);
5711      else
5712         gc_reg_write(index,data & 0x0f);
5713      break;
5714   case 0x09:  // Offset register 0
5715      gc_bank_0 = data;
5716      logerror("CL: Offset register 0 set to %i\n",data);
5717      break;
5718   case 0x0a:  // Offset register 1
5719      gc_bank_1 = data;
5720      logerror("CL: Offset register 1 set to %i\n",data);
5721      break;
5722   case 0x0b:  // Graphics controller mode extensions
5723      gc_mode_ext = data;
5724      break;
5725   case 0x0c:  // Colour Key
5726      break;
5727   case 0x0d:  // Colour Key Mask
5728      break;
5729   case 0x0e:  // Miscellaneous Control
5730      break;
5731   case 0x10:  // Foreground Colour Byte 1
5732      break;
5733   case 0x11:  // Background Colour Byte 1
5734      break;
5735      // later registers are related to the BitBLT hardware
5736   default:
5737      gc_reg_write(index,data);
5738   }
5739}
5740
56215741READ8_MEMBER(cirrus_vga_device::port_03c0_r)
56225742{
56235743   UINT8 res;
r22817r22818
56275747      case 0x05:
56285748         res = cirrus_seq_reg_read(vga.sequencer.index);
56295749         break;
5750      case 0x0f:
5751         res = cirrus_gc_reg_read(vga.gc.index);
5752         break;
56305753      default:
56315754         res = vga_device::port_03c0_r(space,offset,mem_mask);
56325755         break;
r22817r22818
56425765      case 0x05:
56435766         cirrus_seq_reg_write(vga.sequencer.index,data);
56445767         break;
5768      case 0x0f:
5769         cirrus_gc_reg_write(vga.gc.index,data);
5770         break;
56455771      default:
56465772         vga_device::port_03c0_w(space,offset,data,mem_mask);
56475773         break;
56485774   }
56495775   cirrus_define_video_mode();
56505776}
5777
5778READ8_MEMBER(cirrus_vga_device::port_03b0_r)
5779{
5780   UINT8 res = 0xff;
5781
5782   if (CRTC_PORT_ADDR == 0x3b0)
5783   {
5784      switch(offset)
5785      {
5786         case 5:
5787            res = cirrus_crtc_reg_read(vga.crtc.index);
5788            break;
5789         default:
5790            res = vga_device::port_03b0_r(space,offset,mem_mask);
5791            break;
5792      }
5793   }
5794
5795   return res;
5796}
5797
5798READ8_MEMBER(cirrus_vga_device::port_03d0_r)
5799{
5800   UINT8 res = 0xff;
5801
5802   if (CRTC_PORT_ADDR == 0x3d0)
5803   {
5804      switch(offset)
5805      {
5806         case 5:
5807            res = cirrus_crtc_reg_read(vga.crtc.index);
5808            break;
5809         default:
5810            res = vga_device::port_03d0_r(space,offset,mem_mask);
5811            break;
5812      }
5813   }
5814
5815   return res;
5816}
5817
5818WRITE8_MEMBER(cirrus_vga_device::port_03b0_w)
5819{
5820   if (CRTC_PORT_ADDR == 0x3b0)
5821   {
5822      switch(offset)
5823      {
5824         case 5:
5825            vga.crtc.data[vga.crtc.index] = data;
5826            cirrus_crtc_reg_write(vga.crtc.index,data);
5827            break;
5828         default:
5829            vga_device::port_03b0_w(space,offset,data,mem_mask);
5830            break;
5831      }
5832   }
5833}
5834
5835WRITE8_MEMBER(cirrus_vga_device::port_03d0_w)
5836{
5837   if (CRTC_PORT_ADDR == 0x3d0)
5838   {
5839      switch(offset)
5840      {
5841         case 5:
5842            vga.crtc.data[vga.crtc.index] = data;
5843            cirrus_crtc_reg_write(vga.crtc.index,data);
5844            break;
5845         default:
5846            vga_device::port_03d0_w(space,offset,data,mem_mask);
5847            break;
5848      }
5849   }
5850}
5851
5852UINT8 cirrus_vga_device::cirrus_crtc_reg_read(UINT8 index)
5853{
5854   UINT8 res = 0xff;
5855
5856   if(index <= 0x18)
5857      return crtc_reg_read(index);
5858
5859   switch(index)
5860   {
5861   case 0x27:
5862      res = 0xa0;
5863      break;
5864   default:
5865      logerror("CL: Unhandled extended CRTC register CR%02x read\n",index);
5866   }
5867
5868   return res;
5869}
5870
5871void cirrus_vga_device::cirrus_crtc_reg_write(UINT8 index, UINT8 data)
5872{
5873   if(index <= 0x18)
5874   {
5875      crtc_reg_write(index,data);
5876      return;
5877   }
5878   switch(index)
5879   {
5880   case 0x27:
5881      // Do nothing, read only
5882      break;
5883   default:
5884      logerror("CL: Unhandled extended CRTC register CR%02x write %02x\n",index,data);
5885   }
5886
5887}
5888
5889READ8_MEMBER(cirrus_vga_device::mem_r)
5890{
5891   if(svga.rgb8_en || svga.rgb15_en || svga.rgb16_en || svga.rgb24_en)
5892   {
5893      offset &= 0xffff;
5894      if(gc_mode_ext & 0x20)
5895         return vga.memory[(offset+gc_bank_0*0x4000)];
5896      else
5897         return vga.memory[(offset+gc_bank_0*0x1000)];
5898   }
5899
5900   return vga_device::mem_r(space,offset,mem_mask);
5901}
5902
5903WRITE8_MEMBER(cirrus_vga_device::mem_w)
5904{
5905   if(svga.rgb8_en || svga.rgb15_en || svga.rgb16_en || svga.rgb24_en)
5906   {
5907      offset &= 0xffff;
5908      if(gc_mode_ext & 0x20)
5909         vga.memory[(offset+gc_bank_0*0x4000)] = data;
5910      else
5911         vga.memory[(offset+gc_bank_0*0x1000)] = data;
5912   }
5913   else
5914      vga_device::mem_w(space,offset,data,mem_mask);
5915}
trunk/src/emu/video/pc_vga.h
r22817r22818
6161   UINT8 gc_reg_read(UINT8 index);
6262   void attribute_reg_write(UINT8 index, UINT8 data);
6363   void gc_reg_write(UINT8 index,UINT8 data);
64   virtual UINT16 offset();
6465private:
6566   inline UINT8 rotate_right(UINT8 val);
6667   inline UINT8 vga_logical_op(UINT8 data, UINT8 plane, UINT8 mask);
r22817r22818
505506   WRITE8_MEMBER(ati_port_ext_w);
506507
507508   virtual machine_config_constructor device_mconfig_additions() const;
509   virtual UINT16 offset();
508510
509511   mach8_device* get_8514() { return m_8514; }
510512protected:
r22817r22818
585587      UINT8 cursor_bg_ptr;
586588      UINT8 extended_dac_ctrl;
587589   } s3;
590   virtual UINT16 offset();
588591
589592private:
590593   UINT8 s3_crtc_reg_read(UINT8 index);
r22817r22818
632635
633636   virtual READ8_MEMBER(port_03c0_r);
634637   virtual WRITE8_MEMBER(port_03c0_w);
638   virtual READ8_MEMBER(port_03b0_r);
639   virtual WRITE8_MEMBER(port_03b0_w);
640   virtual READ8_MEMBER(port_03d0_r);
641   virtual WRITE8_MEMBER(port_03d0_w);
642   virtual READ8_MEMBER(mem_r);
643   virtual WRITE8_MEMBER(mem_w);
635644protected:
636645   // device-level overrides
637646   virtual void device_start();
647   virtual UINT16 offset();
648
649   UINT8 gc_mode_ext;
650   UINT8 gc_bank_0;
651   UINT8 gc_bank_1;
638652private:
639653   void cirrus_define_video_mode();
640654   UINT8 cirrus_seq_reg_read(UINT8 index);
641655   void cirrus_seq_reg_write(UINT8 index, UINT8 data);
656   UINT8 cirrus_gc_reg_read(UINT8 index);
657   void cirrus_gc_reg_write(UINT8 index, UINT8 data);
658   UINT8 cirrus_crtc_reg_read(UINT8 index);
659   void cirrus_crtc_reg_write(UINT8 index, UINT8 data);
642660};
643661
644662// device type definition

Previous 199869 Revisions Next


© 1997-2024 The MAME Team