diff --git a/src/hardware/vga_attr.cpp b/src/hardware/vga_attr.cpp index 332bdb6a..7a06a04d 100644 --- a/src/hardware/vga_attr.cpp +++ b/src/hardware/vga_attr.cpp @@ -28,12 +28,10 @@ void VGA_ATTR_SetPalette(Bit8u index,Bit8u val) { val &= 63; val |= (vga.attr.color_select & 0xc) << 4; if (GCC_UNLIKELY(!IS_VGA_ARCH)) { - if ((vga.misc_output&0xc4)==0x40) { - if (val&0x10) val|=0x38; - else { - val&=0x7; - if (val==6) val=0x14; - } + if (val&0x10) val|=0x38; + else { + val&=0x7; + if (val==6) val=0x14; } } VGA_DAC_CombineColor(index,val); diff --git a/src/hardware/vga_draw.cpp b/src/hardware/vga_draw.cpp index 8d6191f2..365abf7b 100644 --- a/src/hardware/vga_draw.cpp +++ b/src/hardware/vga_draw.cpp @@ -584,6 +584,7 @@ static void VGA_VerticalTimer(Bitu val) { vga.draw.address_line = vga.config.hlines_skip; vga.draw.split_line = (vga.config.line_compare/vga.draw.lines_scaled); // go figure... + if (machine==MCH_EGA) vga.draw.split_line*=2; // if (machine==MCH_EGA) vga.draw.split_line = ((((vga.config.line_compare&0x5ff)+1)*2-1)/vga.draw.lines_scaled); switch (vga.mode) { case M_EGA: @@ -637,8 +638,10 @@ static void VGA_VerticalTimer(Bitu val) { PIC_AddEvent(VGA_DrawPart,(float)vga.draw.delay.parts,vga.draw.parts_lines); // PIC_AddEvent(VGA_DrawPart,(float)(vga.draw.delay.parts/2),vga.draw.parts_lines); //Else tearline in Tyrian and second reality if (GCC_UNLIKELY(machine==MCH_EGA)) { - PIC_ActivateIRQ(2); - vga.draw.vret_triggered=true; + if (!(vga.crtc.vertical_retrace_end&0x20)) { + PIC_ActivateIRQ(2); + vga.draw.vret_triggered=true; + } } } @@ -787,7 +790,7 @@ void VGA_SetupDrawing(Bitu val) { if (vga.s3.pll.cmd & 0x10) clock/=2; if (IS_VGA_ARCH) vga.draw.double_scan=(vga.crtc.maximum_scan_line&0x80)>0; - else vga.draw.double_scan=false; // might actually be a special implementation of double scanning for ega + else vga.draw.double_scan=(vga.seq.clocking_mode&0x08)>0; // not really correct... } else { htotal = vga.other.htotal + 1; hdend = vga.other.hdend; @@ -850,7 +853,7 @@ void VGA_SetupDrawing(Bitu val) { /* // just curious LOG_MSG("H total %d, V Total %d",htotal,vtotal); - LOG_MSG("H D End %d, V D End %d",hdispend,vdispend); + LOG_MSG("H D End %d, V D End %d",hdend,vdend); LOG_MSG("vrstart: %d, vrend: %d\n",vrstart,vrend); LOG_MSG("htotal: %2.6f, vtotal: %2.6f,\n"\ "hblkstart: %2.6f, hblkend: %2.6f,\n"\ @@ -861,8 +864,8 @@ void VGA_SetupDrawing(Bitu val) { vga.draw.delay.hblkstart, vga.draw.delay.hblkend, vga.draw.delay.vblkstart, vga.draw.delay.vblkend, vga.draw.delay.vrstart, vga.draw.delay.vrend, - vga.draw.delay.vend); - */ + vga.draw.delay.vdend); + */ vga.draw.parts_total=VGA_PARTS; /* 6 Horizontal Sync Polarity. Negative if set @@ -904,6 +907,7 @@ void VGA_SetupDrawing(Bitu val) { vga.draw.delay.parts = vga.draw.delay.vdend/vga.draw.parts_total; vga.draw.resizing=false; + vga.draw.vret_triggered=false; //Check to prevent useless black areas if (hbstarttype) { case M_TEXT: seq_data[2]|=0x3; //Enable plane 0 and 1 - seq_data[4]|=0x05; //Alpanumeric and odd/even enabled + seq_data[4]|=0x01; //Alpanumeric + if (IS_VGA_ARCH) seq_data[4]|=0x04; //odd/even enabled break; case M_CGA2: seq_data[2]|=0xf; //Enable plane 0 + if (machine==MCH_EGA) seq_data[4]|=0x04; //odd/even enabled + break; + case M_CGA4: + if (machine==MCH_EGA) seq_data[2]|=0x03; //Enable plane 0 and 1 break; case M_LIN4: case M_EGA: seq_data[2]|=0xf; //Enable all planes for writing + if (machine==MCH_EGA) seq_data[4]|=0x04; //odd/even enabled break; case M_LIN8: //Seems to have the same reg layout from testing case M_LIN15: @@ -669,8 +675,7 @@ bool INT10_SetVideoMode(Bitu mode) { Bit8u underline=0; /* Maximum scanline / Underline Location */ if (CurMode->special & _EGA_LINE_DOUBLE) { - if (machine==MCH_EGA) max_scanline=1; - else max_scanline|=0x80; + if (machine!=MCH_EGA) max_scanline|=0x80; } switch (CurMode->type) { case M_TEXT: @@ -689,8 +694,7 @@ bool INT10_SetVideoMode(Bitu mode) { break; case M_CGA2: case M_CGA4: - if (machine==MCH_EGA) max_scanline|=2; - else max_scanline|=1; + max_scanline|=1; break; } if (CurMode->vdispend==350) underline=0x0f; @@ -719,6 +723,9 @@ bool INT10_SetVideoMode(Bitu mode) { break; default: offset = CurMode->hdispend/2; + if ((machine==MCH_EGA) && (CurMode->type==M_EGA)) { + if (!(CurMode->special & _EGA_LINE_DOUBLE)) offset/=2; + } } IO_Write(crtc_base,0x13); IO_Write(crtc_base + 1,offset & 0xff); @@ -746,8 +753,14 @@ bool INT10_SetVideoMode(Bitu mode) { case M_EGA: if (CurMode->mode==0x11) // 0x11 also sets address wrap. thought maybe all 2 color modes did but 0x0f doesn't. mode_control=0xc3; // so.. 0x11 or 0x0f a one off? - else - mode_control=0xe3; + else { + if (machine==MCH_EGA) { + if (CurMode->special & _EGA_LINE_DOUBLE) mode_control=0xc3; + else mode_control=0x8b; + } else { + mode_control=0xe3; + } + } break; case M_TEXT: case M_VGA: @@ -760,6 +773,7 @@ bool INT10_SetVideoMode(Bitu mode) { mode_control |= 0x08; break; } + if (machine==MCH_EGA) mode_control|=0x10; IO_Write(crtc_base,0x17);IO_Write(crtc_base+1,mode_control); /* Renable write protection */ @@ -819,8 +833,15 @@ bool INT10_SetVideoMode(Bitu mode) { break; case M_CGA4: gfx_data[0x5]|=0x20; //CGA mode - case M_CGA2: gfx_data[0x6]|=0x0f; //graphics mode at at 0xb800=0xbfff + if (machine==MCH_EGA) gfx_data[0x5]|=0x10; + break; + case M_CGA2: + if (machine==MCH_EGA) { + gfx_data[0x6]|=0x0d; //graphics mode at at 0xb800=0xbfff + } else { + gfx_data[0x6]|=0x0f; //graphics mode at at 0xb800=0xbfff + } break; } for (i=0;itype == M_LIN4 ) goto att_text16; - if (!IS_VGA_ARCH) { - for (i=0;i<8;i++) { - att_data[i]=i; - att_data[i+8]=i+0x38; - } - } else { - for (i=0;i<8;i++) { - att_data[i]=i; - att_data[i+8]=i+0x10; - } + for (i=0;i<8;i++) { + att_data[i]=i; + att_data[i+8]=i+0x10; } break; } @@ -874,15 +888,27 @@ bool INT10_SetVideoMode(Bitu mode) { for (i=0;i<16;i++) att_data[i]=i; break; case M_TEXT: - att_data[0x13]=0x08; //Pel panning on 8, although we don't have 9 dot text mode - att_data[0x10]=0x0C; //Color Text with blinking + if (machine==MCH_EGA) { + att_data[0x13]=0x00; + att_data[0x10]=0x08; //8 Bit characters + } else { + att_data[0x13]=0x08; //Pel panning on 8, although we don't have 9 dot text mode + att_data[0x10]=0x0C; //Color Text with blinking + } real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,0x30); att_text16: - for (i=0;i<8;i++) { - att_data[i]=i; - att_data[i+8]=i+0x38; + if (machine==MCH_EGA) { + for (i=0;i<8;i++) { + att_data[i]=i; + att_data[i+8]=i+0x10; + } + } else { + for (i=0;i<8;i++) { + att_data[i]=i; + att_data[i+8]=i+0x38; + } } - att_data[0x06]=0x14; //Odd Color 6 yellow/brown. + if (IS_VGA_ARCH) att_data[0x06]=0x14; //Odd Color 6 yellow/brown. break; case M_CGA2: att_data[0x10]=0x01; //Color Graphics