Previous 15994 Revisions Next

r14100 Thursday 19th January, 2012 at 23:00:33 UTC by Angelo Salese
Fix aspect ratio, now 256 colors outputs at 640 x 400 / 480
[src/emu/video]pc_vga.c

src/emu/video/pc_vga.c
r14099r14100
2020    - modernize
2121    - convert to an ISA device.
2222    - add emulated mc6845 hook-up
23    - fix resolution change
2423    - fix video update.
2524   - rewrite video drawing functions (they are horrible)
2625   - add emulated CGA
r14099r14100
8685/**/   UINT8 disp_enable_skew;
8786/**/   UINT8 evra;
8887      UINT16 vert_total;
88      UINT16 vert_disp_end;
8989/**/   UINT16 vert_retrace_start;
9090/**/   UINT8 vert_retrace_end;
91      UINT16 vert_disp_end;
9291/**/   UINT16 vert_blank_start;
9392      UINT16 line_compare;
9493/**/   UINT16 cursor_addr;
r14099r14100
323322   }
324323}
325324
325/* TODO: I'm guessing that in 256 colors mode every pixel actually outputs two pixels. Is it right? */
326326static void vga_vh_vga(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
327327{
328328   int pos, line, column, c, addr, curr_addr;
r14099r14100
330330   UINT16 mask_comp;
331331   int height = vga.crtc.maximum_scan_line * (vga.crtc.scan_doubling + 1);
332332   int yi;
333   int xi,xi_h;
333334
334335   /* line compare is screen sensitive */
335336   mask_comp = 0x0ff | (LINES & 0x300);
r14099r14100
347348               curr_addr = 0;
348349            bitmapline = &bitmap.pix32(line + yi);
349350            addr %= vga.svga_intf.vram_size;
350            for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x20)
351            for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=0x10, pos+=0x20)
351352            {
352353               if(pos + 0x20 > vga.svga_intf.vram_size)
353354                  return;
354               bitmapline[c+0] = machine.pens[vga.memory[pos+0]];
355               bitmapline[c+1] = machine.pens[vga.memory[pos+1]];
356               bitmapline[c+2] = machine.pens[vga.memory[pos+2]];
357               bitmapline[c+3] = machine.pens[vga.memory[pos+3]];
358               bitmapline[c+4] = machine.pens[vga.memory[pos+0x10]];
359               bitmapline[c+5] = machine.pens[vga.memory[pos+0x11]];
360               bitmapline[c+6] = machine.pens[vga.memory[pos+0x12]];
361               bitmapline[c+7] = machine.pens[vga.memory[pos+0x13]];
355
356               for(xi=0;xi<0x10;xi++)
357               {
358                  xi_h = ((xi & 6) >> 1) | ((xi & 8) << 1);
359                  bitmapline[c+xi] = machine.pens[vga.memory[pos+xi_h]];
360               }
362361            }
363362         }
364363      }
r14099r14100
375374               curr_addr = 0;
376375            bitmapline = &bitmap.pix32(line + yi);
377376            addr %= vga.svga_intf.vram_size;
378            for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x08)
377            for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=0x10, pos+=0x08)
379378            {
380379               if(pos + 0x08 > vga.svga_intf.vram_size)
381380                  return;
382               bitmapline[c+0] = machine.pens[vga.memory[pos+0]];
383               bitmapline[c+1] = machine.pens[vga.memory[pos+1]];
384               bitmapline[c+2] = machine.pens[vga.memory[pos+2]];
385               bitmapline[c+3] = machine.pens[vga.memory[pos+3]];
386               bitmapline[c+4] = machine.pens[vga.memory[pos+4]];
387               bitmapline[c+5] = machine.pens[vga.memory[pos+5]];
388               bitmapline[c+6] = machine.pens[vga.memory[pos+6]];
389               bitmapline[c+7] = machine.pens[vga.memory[pos+7]];
381
382               for(xi=0;xi<0x10;xi++)
383               {
384                  xi_h = (xi & 0xe) >> 1;
385                  bitmapline[c+xi] = machine.pens[vga.memory[pos+xi_h]];
386               }
390387            }
391388         }
392389      }
r14099r14100
724721{
725722   int vblank_period,hblank_period;
726723   attoseconds_t refresh;
727   UINT8 hclock_m,hclock_d;
724   UINT8 hclock_m;
728725   int pixel_clock;
729726
730727   hclock_m = (!GRAPHIC_MODE) ? CHAR_WIDTH : 8;
731728
732   /* TODO: actually display is 640 x 400 in "VGA" mode */
733   if(!GRAPHIC_MODE)
734      hclock_d = CHAR_WIDTH;
735   else
736      hclock_d = vga.gc.data[5]&0x40 ? 4 : 8;
729   rectangle visarea(0, ((vga.crtc.horz_disp_end + 1) * hclock_m)-1, 0, vga.crtc.vert_disp_end);
737730
738   rectangle visarea(0, ((vga.crtc.horz_disp_end + 1) * hclock_d)-1, 0, vga.crtc.vert_disp_end);
739
740731   vblank_period = (vga.crtc.vert_total + 2);
741732   hblank_period = ((vga.crtc.horz_total + 5) * hclock_m);
742733
r14099r14100
752743
753744static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data)
754745{
746   /* Doom does this */
747//   if(vga.crtc.protect_enable && index <= 0x07)
748//      printf("write to protected address %02x\n",index);
749
755750   switch(index)
756751   {
757752      case 0x00:

Previous 15994 Revisions Next


© 1998-2018 The MESS Team