VGA: Fixed Double Scan / Maximum Scan Lines condition, and removed a bunch of kludges [Angelo Salese]

This commit is contained in:
Angelo Salese 2012-01-17 20:12:25 +00:00
parent f9a76259c2
commit cdda02fa91

View File

@ -18,15 +18,19 @@
TODO: TODO:
- modernize - modernize
- convert to a device. - convert to an ISA device.
- fix pixel clock - fix pixel clock
- add emulated mc6845 hook-up - add emulated mc6845 hook-up
- fix resolution change - fix resolution change
- fix video update. - fix video update.
- fix partial updates (The Incredible Machine) - rewrite video drawing functions (they are horrible)
- check doublescan condition (Robotron) - add emulated CGA
- add VESA etc.
- (and many more ...) - (and many more ...)
per-game issues:
- fix partial updates (The Incredible Machine)
ROM declarations: ROM declarations:
(oti 037 chip) (oti 037 chip)
@ -124,7 +128,8 @@ static struct
#define CRTC_CURSOR_TOP (REG(0xa)&0x1f) #define CRTC_CURSOR_TOP (REG(0xa)&0x1f)
#define CRTC_CURSOR_BOTTOM REG(0xb) #define CRTC_CURSOR_BOTTOM REG(0xb)
#define DOUBLESCAN ((vga.crtc.data[9]&0x80)||((vga.crtc.data[9]&0x1f)!=0)) #define DOUBLESCAN ((vga.crtc.data[9]&0x80)>>7)
#define MAX_SCAN_LINES ((vga.crtc.data[9]&0x1f)+1)
#define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0) #define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0)
#define CRTC_ON (vga.crtc.data[0x17]&0x80) #define CRTC_ON (vga.crtc.data[0x17]&0x80)
@ -133,7 +138,7 @@ static struct
|((vga.crtc.data[7]&2)<<7) \ |((vga.crtc.data[7]&2)<<7) \
|((vga.crtc.data[7]&0x40)<<3))+1 ) |((vga.crtc.data[7]&0x40)<<3))+1 )
//#define TEXT_LINES (LINES_HELPER) //#define TEXT_LINES (LINES_HELPER)
#define LINES (DOUBLESCAN?LINES_HELPER>>1:LINES_HELPER) #define LINES (LINES_HELPER)
#define TEXT_LINES (LINES_HELPER >> ((vga.crtc.data[9]&0x80) ? 1 : 0)) #define TEXT_LINES (LINES_HELPER >> ((vga.crtc.data[9]&0x80) ? 1 : 0))
#define GRAPHIC_MODE (vga.gc.data[6]&1) /* else textmodus */ #define GRAPHIC_MODE (vga.gc.data[6]&1) /* else textmodus */
@ -255,16 +260,20 @@ static void vga_vh_text(running_machine &machine, bitmap_rgb32 &bitmap, const re
static void vga_vh_ega(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) static void vga_vh_ega(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{ {
int pos, line, column, c, addr, i; int pos, line, column, c, addr, i, yi;
int height = CRTC_CHAR_HEIGHT; int height = MAX_SCAN_LINES * (DOUBLESCAN + 1);
UINT32 *bitmapline; UINT32 *bitmapline;
UINT32 *newbitmapline;
pen_t pen; pen_t pen;
for (addr=EGA_START_ADDRESS, pos=0, line=0; line<LINES * (DOUBLESCAN+1); for (addr=EGA_START_ADDRESS, pos=0, line=0; line<LINES;
line += height, addr=(addr+EGA_LINE_LENGTH)&0x3ffff) line += height, addr=(addr+EGA_LINE_LENGTH)&0x3ffff)
{ {
bitmapline = &bitmap.pix32(line >> DOUBLESCAN); for(yi=0;yi<height;yi++)
{
if(!machine.primary_screen->visible_area().contains(0, line + yi))
return;
bitmapline = &bitmap.pix32(line + yi);
for (pos=addr, c=0, column=0; column<EGA_COLUMNS; column++, c+=8, pos=(pos+4)&0x3ffff) for (pos=addr, c=0, column=0; column<EGA_COLUMNS; column++, c+=8, pos=(pos+4)&0x3ffff)
{ {
@ -286,14 +295,6 @@ static void vga_vh_ega(running_machine &machine, bitmap_rgb32 &bitmap, const re
data[3]>>=1; data[3]>>=1;
} }
} }
for (i = 1; i < height; i++)
{
if (line + i >= LINES)
break;
newbitmapline = &bitmap.pix32(line+i);
memcpy(newbitmapline, bitmapline, EGA_COLUMNS * 8 * sizeof(UINT16));
} }
} }
} }
@ -303,20 +304,24 @@ static void vga_vh_vga(running_machine &machine, bitmap_rgb32 &bitmap, const rec
int pos, line, column, c, addr, curr_addr; int pos, line, column, c, addr, curr_addr;
UINT32 *bitmapline; UINT32 *bitmapline;
UINT16 mask_comp; UINT16 mask_comp;
int height = MAX_SCAN_LINES * (DOUBLESCAN + 1);
int yi;
/* line compare is screen sensitive */ /* line compare is screen sensitive */
mask_comp = 0xff | (LINES & 0x300); mask_comp = 0x0ff | (LINES & 0x300);
curr_addr = 0; curr_addr = 0;
if(vga.sequencer.data[4] & 0x08) if(vga.sequencer.data[4] & 0x08)
{ {
for (addr = VGA_START_ADDRESS, line=0; line<LINES; line++, addr+=VGA_LINE_LENGTH, curr_addr+=VGA_LINE_LENGTH) for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=VGA_LINE_LENGTH, curr_addr+=VGA_LINE_LENGTH)
{ {
if(line < (vga.line_compare & mask_comp)) for(yi = 0;yi < height; yi++)
{
if((line + yi) < (vga.line_compare & mask_comp))
curr_addr = addr; curr_addr = addr;
if(line == (vga.line_compare & mask_comp)) if((line + yi) == (vga.line_compare & mask_comp))
curr_addr = 0; curr_addr = 0;
bitmapline = &bitmap.pix32(line); bitmapline = &bitmap.pix32(line + yi);
addr %= vga.svga_intf.vram_size; addr %= vga.svga_intf.vram_size;
for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x20) for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x20)
{ {
@ -333,15 +338,18 @@ static void vga_vh_vga(running_machine &machine, bitmap_rgb32 &bitmap, const rec
} }
} }
} }
}
else else
{ {
for (addr = VGA_START_ADDRESS, line=0; line<LINES; line++, addr+=VGA_LINE_LENGTH/4, curr_addr+=VGA_LINE_LENGTH/4) for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=VGA_LINE_LENGTH/4, curr_addr+=VGA_LINE_LENGTH/4)
{ {
if(line < (vga.line_compare & mask_comp)) for(yi = 0;yi < height; yi++)
{
if((line + yi) < (vga.line_compare & mask_comp))
curr_addr = addr; curr_addr = addr;
if(line == (vga.line_compare & mask_comp)) if((line + yi) == (vga.line_compare & mask_comp))
curr_addr = 0; curr_addr = 0;
bitmapline = &bitmap.pix32(line); bitmapline = &bitmap.pix32(line + yi);
addr %= vga.svga_intf.vram_size; addr %= vga.svga_intf.vram_size;
for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x08) for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x08)
{ {
@ -358,6 +366,7 @@ static void vga_vh_vga(running_machine &machine, bitmap_rgb32 &bitmap, const rec
} }
} }
} }
}
} }
static UINT8 pc_vga_choosevideomode(running_machine &machine, int *width, int *height) static UINT8 pc_vga_choosevideomode(running_machine &machine, int *width, int *height)
@ -799,7 +808,7 @@ static WRITE8_HANDLER(vga_crtc_w)
data); data);
} }
if(vga.crtc.index == 0x18 || vga.crtc.index == 0x07 || vga.crtc.index == 0x19 ) // Line compare if(vga.crtc.index == 0x18 || vga.crtc.index == 0x07 || vga.crtc.index == 0x19 ) // Line compare
vga.line_compare = (((vga.crtc.data[0x09] & 0x40) << 3) | ((vga.crtc.data[0x07] & 0x10) << 4) | vga.crtc.data[0x18])/2; vga.line_compare = (((vga.crtc.data[0x09] & 0x40) << 3) | ((vga.crtc.data[0x07] & 0x10) << 4) | vga.crtc.data[0x18]);
if (vga.crtc.index < vga.svga_intf.crtc_regcount) if (vga.crtc.index < vga.svga_intf.crtc_regcount)
vga.crtc.data[vga.crtc.index] = data; vga.crtc.data[vga.crtc.index] = data;