From 56d19f4f8d19a854f645a41c89e933be8342f48e Mon Sep 17 00:00:00 2001 From: Ralf Grillenberger Date: Sun, 16 Jun 2013 20:42:27 +0000 Subject: [PATCH] By implementing Tandy special handling of the palette: - fix Starflight background color (reported by HunterZ) - keep Pirates! map background correct Also fix the palette after mode switch on the PCJr. Fixes Frogger II composite mode color attributes (reported by VileRancour). Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3832 --- src/hardware/vga_other.cpp | 25 +++++++++++++------------ src/ints/int10_pal.cpp | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/hardware/vga_other.cpp b/src/hardware/vga_other.cpp index 98f28e75..cb8508f7 100644 --- a/src/hardware/vga_other.cpp +++ b/src/hardware/vga_other.cpp @@ -438,9 +438,7 @@ static void tandy_update_palette() { switch (vga.mode) { case M_TANDY2: VGA_SetCGA2Table(vga.attr.palette[0], - //vga.attr.palette[vga.tandy.color_select&0xf]); - vga.attr.palette[0xf]); - //VGA_SetCGA2Table(vga.attr.palette[0xf],vga.attr.palette[0]); + vga.attr.palette[vga.tandy.color_select&0xf]); break; case M_TANDY4: if (vga.tandy.gfx_control & 0x8) { @@ -458,7 +456,7 @@ static void tandy_update_palette() { r_mask &= ~1; } VGA_SetCGA4Table( - vga.attr.palette[0], + vga.attr.palette[vga.tandy.color_select&0xf], vga.attr.palette[(2|color_set)& vga.tandy.palette_mask], vga.attr.palette[(4|(color_set& r_mask))& vga.tandy.palette_mask], vga.attr.palette[(6|color_set)& vga.tandy.palette_mask]); @@ -523,6 +521,7 @@ static void PCJr_FindMode(void) { if (vga.mode==M_TANDY16) VGA_SetModeNow(M_TANDY4); else VGA_SetMode(M_TANDY4); } + tandy_update_palette(); } else { VGA_SetMode(M_TANDY_TEXT); } @@ -588,17 +587,19 @@ static void write_tandy_reg(Bit8u val) { static void write_tandy(Bitu port,Bitu val,Bitu /*iolen*/) { switch (port) { case 0x3d8: - vga.tandy.mode_control=(Bit8u)val; - if (val&0x8) vga.attr.disabled &= ~1; - else vga.attr.disabled |= 1; - TandyCheckLineMask(); - VGA_SetBlinking(val & 0x20); - TANDY_FindMode(); + val &= 0x3f; // only bits 0-6 are used + if (vga.tandy.mode_control ^ val) { + vga.tandy.mode_control=(Bit8u)val; + if (val&0x8) vga.attr.disabled &= ~1; + else vga.attr.disabled |= 1; + TandyCheckLineMask(); + VGA_SetBlinking(val & 0x20); + TANDY_FindMode(); + VGA_StartResize(); + } break; case 0x3d9: vga.tandy.color_select=val; - if (vga.mode==M_TANDY2) vga.attr.palette[0xf] = vga.tandy.color_select&0xf; - else vga.attr.palette[0] = vga.tandy.color_select&0xf; // Pirates! tandy_update_palette(); break; case 0x3da: diff --git a/src/ints/int10_pal.cpp b/src/ints/int10_pal.cpp index a580220f..f6889a48 100644 --- a/src/ints/int10_pal.cpp +++ b/src/ints/int10_pal.cpp @@ -92,6 +92,7 @@ void INT10_SetOverscanBorderColor(Bit8u val) { case TANDY_ARCH_CASE: IO_Read(VGAREG_TDY_RESET); WriteTandyACTL(0x02,val); + IO_Write(VGAREG_TDY_ADDRESS, 0); // enable the screen break; case EGAVGA_ARCH_CASE: ResetACTL(); @@ -308,9 +309,37 @@ void INT10_SetBackgroundBorder(Bit8u val) { color_select=(color_select & 0xe0) | (val & 0x1f); real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,color_select); - if (machine == MCH_CGA || machine == MCH_TANDY) + switch (machine) { + case MCH_CGA: + // only write the color select register IO_Write(0x3d9,color_select); - else if (machine == MCH_PCJR) { + break; + case MCH_TANDY: + // TODO handle val == 0x1x, wait for retrace + switch(CurMode->mode) { + default: // modes 0-5: write to color select and border + INT10_SetOverscanBorderColor(val); + IO_Write(0x3d9, color_select); + break; + case 0x06: // 2-color: only write the color select register + IO_Write(0x3d9, color_select); + break; + case 0x07: // Tandy monochrome not implemented + break; + case 0x08: + case 0x09: // 16-color: write to color select, border and pal. index 0 + INT10_SetOverscanBorderColor(val); + INT10_SetSinglePaletteRegister(0, val); + IO_Write(0x3d9, color_select); + break; + case 0x0a: // 4-color highres: + // write zero to color select, write palette to indexes 1-3 + // TODO palette + IO_Write(0x3d9, 0); + break; + } + break; + case MCH_PCJR: IO_Read(VGAREG_TDY_RESET); // reset the flipflop if (vga.mode!=M_TANDY_TEXT) { IO_Write(VGAREG_TDY_ADDRESS, 0x10); @@ -318,8 +347,8 @@ void INT10_SetBackgroundBorder(Bit8u val) { } IO_Write(VGAREG_TDY_ADDRESS, 0x2); // border color IO_Write(VGAREG_PCJR_DATA, color_select&0xf); - } - else if (IS_EGAVGA_ARCH) { + break; + case EGAVGA_ARCH_CASE: val = ((val << 1) & 0x10) | (val & 0x7); /* Always set the overscan color */ INT10_SetSinglePaletteRegister( 0x11, val ); @@ -333,6 +362,7 @@ void INT10_SetBackgroundBorder(Bit8u val) { INT10_SetSinglePaletteRegister( 2, val ); val+=2; INT10_SetSinglePaletteRegister( 3, val ); + break; } }