src/emu/video/pc_vga.c
| r14099 | r14100 | |
| 20 | 20 | - modernize |
| 21 | 21 | - convert to an ISA device. |
| 22 | 22 | - add emulated mc6845 hook-up |
| 23 | | - fix resolution change |
| 24 | 23 | - fix video update. |
| 25 | 24 | - rewrite video drawing functions (they are horrible) |
| 26 | 25 | - add emulated CGA |
| r14099 | r14100 | |
| 86 | 85 | /**/ UINT8 disp_enable_skew; |
| 87 | 86 | /**/ UINT8 evra; |
| 88 | 87 | UINT16 vert_total; |
| 88 | UINT16 vert_disp_end; |
| 89 | 89 | /**/ UINT16 vert_retrace_start; |
| 90 | 90 | /**/ UINT8 vert_retrace_end; |
| 91 | | UINT16 vert_disp_end; |
| 92 | 91 | /**/ UINT16 vert_blank_start; |
| 93 | 92 | UINT16 line_compare; |
| 94 | 93 | /**/ UINT16 cursor_addr; |
| r14099 | r14100 | |
| 323 | 322 | } |
| 324 | 323 | } |
| 325 | 324 | |
| 325 | /* TODO: I'm guessing that in 256 colors mode every pixel actually outputs two pixels. Is it right? */ |
| 326 | 326 | static void vga_vh_vga(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 327 | 327 | { |
| 328 | 328 | int pos, line, column, c, addr, curr_addr; |
| r14099 | r14100 | |
| 330 | 330 | UINT16 mask_comp; |
| 331 | 331 | int height = vga.crtc.maximum_scan_line * (vga.crtc.scan_doubling + 1); |
| 332 | 332 | int yi; |
| 333 | int xi,xi_h; |
| 333 | 334 | |
| 334 | 335 | /* line compare is screen sensitive */ |
| 335 | 336 | mask_comp = 0x0ff | (LINES & 0x300); |
| r14099 | r14100 | |
| 347 | 348 | curr_addr = 0; |
| 348 | 349 | bitmapline = &bitmap.pix32(line + yi); |
| 349 | 350 | 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) |
| 351 | 352 | { |
| 352 | 353 | if(pos + 0x20 > vga.svga_intf.vram_size) |
| 353 | 354 | 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 | } |
| 362 | 361 | } |
| 363 | 362 | } |
| 364 | 363 | } |
| r14099 | r14100 | |
| 375 | 374 | curr_addr = 0; |
| 376 | 375 | bitmapline = &bitmap.pix32(line + yi); |
| 377 | 376 | 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) |
| 379 | 378 | { |
| 380 | 379 | if(pos + 0x08 > vga.svga_intf.vram_size) |
| 381 | 380 | 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 | } |
| 390 | 387 | } |
| 391 | 388 | } |
| 392 | 389 | } |
| r14099 | r14100 | |
| 724 | 721 | { |
| 725 | 722 | int vblank_period,hblank_period; |
| 726 | 723 | attoseconds_t refresh; |
| 727 | | UINT8 hclock_m,hclock_d; |
| 724 | UINT8 hclock_m; |
| 728 | 725 | int pixel_clock; |
| 729 | 726 | |
| 730 | 727 | hclock_m = (!GRAPHIC_MODE) ? CHAR_WIDTH : 8; |
| 731 | 728 | |
| 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); |
| 737 | 730 | |
| 738 | | rectangle visarea(0, ((vga.crtc.horz_disp_end + 1) * hclock_d)-1, 0, vga.crtc.vert_disp_end); |
| 739 | | |
| 740 | 731 | vblank_period = (vga.crtc.vert_total + 2); |
| 741 | 732 | hblank_period = ((vga.crtc.horz_total + 5) * hclock_m); |
| 742 | 733 | |
| r14099 | r14100 | |
| 752 | 743 | |
| 753 | 744 | static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data) |
| 754 | 745 | { |
| 746 | /* Doom does this */ |
| 747 | // if(vga.crtc.protect_enable && index <= 0x07) |
| 748 | // printf("write to protected address %02x\n",index); |
| 749 | |
| 755 | 750 | switch(index) |
| 756 | 751 | { |
| 757 | 752 | case 0x00: |