From 1d71454869dee4cc8c109489ac75a078cae4f27a Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Sat, 16 May 2009 06:40:13 +0000 Subject: [PATCH] Properly convert the 6 bit of vga to the 8bit output Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3391 --- src/hardware/vga_dac.cpp | 42 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/hardware/vga_dac.cpp b/src/hardware/vga_dac.cpp index ab971f56..a228521c 100644 --- a/src/hardware/vga_dac.cpp +++ b/src/hardware/vga_dac.cpp @@ -50,16 +50,19 @@ Note: Each read or write of this register will cycle through first the enum {DAC_READ,DAC_WRITE}; -static INLINE void VGA_DAC_UpdateColor( Bitu index ) { +static void VGA_DAC_SendColor( Bitu index, Bitu src ) { + const Bit8u red = vga.dac.rgb[src].red; + const Bit8u green = vga.dac.rgb[src].green; + const Bit8u blue = vga.dac.rgb[src].blue; + //Set entry in 16bit output lookup table + vga.dac.xlat16[index] = ((blue>>1)&0x1f) | (((green)&0x3f)<<5) | (((red>>1)&0x1f) << 11); + + RENDER_SetPal( index, (red << 2) | ( red >> 4 ), (green << 2) | ( green >> 4 ), (blue << 2) | ( blue >> 4 ) ); +} + +static void VGA_DAC_UpdateColor( Bitu index ) { Bitu maskIndex = index & vga.dac.pel_mask; - vga.dac.xlat16[index] = ((vga.dac.rgb[maskIndex].blue>>1)&0x1f) | - (((vga.dac.rgb[maskIndex].green)&0x3f)<<5)| - (((vga.dac.rgb[maskIndex].red>>1)&0x1f) << 11); - RENDER_SetPal( index, - vga.dac.rgb[maskIndex].red << 2, - vga.dac.rgb[maskIndex].green << 2, - vga.dac.rgb[maskIndex].blue << 2 - ); + VGA_DAC_SendColor( index, maskIndex ); } static void write_p3c6(Bitu port,Bitu val,Bitu iolen) { @@ -129,14 +132,7 @@ static void write_p3c9(Bitu port,Bitu val,Bitu iolen) { /* Check for attributes and DAC entry link */ for (Bitu i=0;i<16;i++) { if (vga.dac.combine[i]==vga.dac.write_index) { - vga.dac.xlat16[i] = ( - (vga.dac.rgb[vga.dac.write_index].blue>>1)&0x1f) | - (((vga.dac.rgb[vga.dac.write_index].green)&0x3f)<<5)| - (((vga.dac.rgb[vga.dac.write_index].red>>1)&0x1f) << 11); - RENDER_SetPal(i, - vga.dac.rgb[vga.dac.write_index].red << 2, - vga.dac.rgb[vga.dac.write_index].green << 2, - vga.dac.rgb[vga.dac.write_index].blue << 2); + VGA_DAC_SendColor( i, vga.dac.write_index ); } } } @@ -184,16 +180,8 @@ void VGA_DAC_CombineColor(Bit8u attr,Bit8u pal) { case M_VGA: // used by copper demo; almost no video card seems to suport it if(!IS_VGA_ARCH || (svgaCard!=SVGA_None)) break; - default: - vga.dac.xlat16[attr] = ((vga.dac.rgb[pal].blue>>1)&0x1f) | - (((vga.dac.rgb[pal].green)&0x3f)<<5)| - (((vga.dac.rgb[pal].red>>1)&0x1f) << 11); - RENDER_SetPal(attr, - vga.dac.rgb[pal].red << 2, - vga.dac.rgb[pal].green << 2, - vga.dac.rgb[pal].blue << 2 - ); + VGA_DAC_SendColor( attr, pal ); } } @@ -204,7 +192,7 @@ void VGA_DAC_SetEntry(Bitu entry,Bit8u red,Bit8u green,Bit8u blue) { vga.dac.rgb[entry].blue=blue; for (Bitu i=0;i<16;i++) if (vga.dac.combine[i]==entry) - RENDER_SetPal(i,red << 2,green << 2,blue << 2); + VGA_DAC_SendColor( i, i ); } void VGA_SetupDAC(void) {