[PATCH] Improve doubled TV monitor mode look

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Having every other line black as earlier, makes the screen too dark.
Copy the line with half the intensity instead.

This was request from Atari-forum:
	http://www.atari-forum.com/viewtopic.php?f=51&t=27730
---
 src/convert/low640x16.c      |  2 +-
 src/convert/low640x16_spec.c |  2 +-
 src/convert/low640x32.c      |  2 +-
 src/convert/low640x32_spec.c |  2 +-
 src/convert/med640x16.c      |  2 +-
 src/convert/med640x16_spec.c |  2 +-
 src/convert/med640x32.c      |  2 +-
 src/convert/med640x32_spec.c |  2 +-
 src/screen.c                 | 38 +++++++++++++++++++++++++++++++-----
 9 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/src/convert/low640x16.c b/src/convert/low640x16.c
index 395c6f70..e55e369f 100644
--- a/src/convert/low640x16.c
+++ b/src/convert/low640x16.c
@@ -82,6 +82,6 @@ static void ConvertLowRes_640x16Bit(void)
 		else
 			Line_ConvertLowRes_640x16Bit(edi, ebp, esi, eax);
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 16);
 	}
 }
diff --git a/src/convert/low640x16_spec.c b/src/convert/low640x16_spec.c
index de06181b..0d83b10a 100644
--- a/src/convert/low640x16_spec.c
+++ b/src/convert/low640x16_spec.c
@@ -25,7 +25,7 @@ static void ConvertLowRes_640x16Bit_Spec(void)
 
 		Line_ConvertLowRes_640x16Bit_Spec(edi, ebp, esi, eax);
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 16);
 	}
 
         bScreenContentsChanged = true;
diff --git a/src/convert/low640x32.c b/src/convert/low640x32.c
index b2614566..2eda7e77 100644
--- a/src/convert/low640x32.c
+++ b/src/convert/low640x32.c
@@ -80,6 +80,6 @@ static void ConvertLowRes_640x32Bit(void)
 		else
 			Line_ConvertLowRes_640x32Bit(edi, ebp, esi, eax);
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 32);
 	}
 }
diff --git a/src/convert/low640x32_spec.c b/src/convert/low640x32_spec.c
index 68aa3709..e4b5ef26 100644
--- a/src/convert/low640x32_spec.c
+++ b/src/convert/low640x32_spec.c
@@ -25,7 +25,7 @@ static void ConvertLowRes_640x32Bit_Spec(void)
 
 		Line_ConvertLowRes_640x32Bit_Spec(edi, ebp, esi, eax);
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 32);
 	}
 
         bScreenContentsChanged = true;
diff --git a/src/convert/med640x16.c b/src/convert/med640x16.c
index 7bfcb82c..c682ec36 100644
--- a/src/convert/med640x16.c
+++ b/src/convert/med640x16.c
@@ -29,7 +29,7 @@ static void ConvertMediumRes_640x16Bit(void)
 		else
 			Line_ConvertLowRes_640x16Bit(edi, ebp, (Uint32 *)esi, eax);
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 16);
 	}
 }
 
diff --git a/src/convert/med640x16_spec.c b/src/convert/med640x16_spec.c
index 2d9ef6bc..1deba844 100644
--- a/src/convert/med640x16_spec.c
+++ b/src/convert/med640x16_spec.c
@@ -28,7 +28,7 @@ static void ConvertMediumRes_640x16Bit_Spec(void)
 		else
 			Line_ConvertLowRes_640x16Bit_Spec(edi, ebp, (Uint32 *)esi, eax);	/* low res line (double on X) */
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 16);
 	}
 
         bScreenContentsChanged = true;
diff --git a/src/convert/med640x32.c b/src/convert/med640x32.c
index 1310c274..21094cf4 100644
--- a/src/convert/med640x32.c
+++ b/src/convert/med640x32.c
@@ -29,7 +29,7 @@ static void ConvertMediumRes_640x32Bit(void)
 		else
 			Line_ConvertLowRes_640x32Bit(edi, ebp, esi, eax);
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 32);
 	}
 }
 
diff --git a/src/convert/med640x32_spec.c b/src/convert/med640x32_spec.c
index cb9c5515..2cc45fd9 100644
--- a/src/convert/med640x32_spec.c
+++ b/src/convert/med640x32_spec.c
@@ -28,7 +28,7 @@ static void ConvertMediumRes_640x32Bit_Spec(void)
 		else
 			Line_ConvertLowRes_640x32Bit_Spec(edi, ebp, esi, eax);		/* low res line (double on X) */
 
-		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine);
+		pPCScreenDest = Double_ScreenLine(pPCScreenDest, PCScreenBytesPerLine, 32);
 	}
 
         bScreenContentsChanged = true;
diff --git a/src/screen.c b/src/screen.c
index e3971fc2..75ba1256 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1604,19 +1604,47 @@ static void Convert_StartFrame(void)
 
 /*-----------------------------------------------------------------------*/
 /**
- * Copy given line (address) of given length, to line below it,
- * or skip it, depending on bScrDoubleY.
+ * Copy given line (address) of given length, to line below it
+ * as-is, or halve its intensity, depending on bScrDoubleY.
+ *
+ * Source line is already in host format, so we don't need to
+ * care about endianess.
  *
  * Return address to next line after the copy
  */
-static Uint8* Double_ScreenLine(Uint8 *line, int size)
+static Uint8* Double_ScreenLine(Uint8 *line, int size, int bits)
 {
+	Uint8 *next = line + size;
 	if (bScrDoubleY)
 	{
-		Uint8 *next = line + size;
 		memcpy(next, line, size);
+		next += size;
+	}
+	/* TV-mode -- halve the intensity while copying */
+	else if (bits == 32)
+	{
+		do {
+			*next++ = *line++ >> 1;
+		}
+		while (--size);
+	}
+	else if (bits == 16)
+	{
+		Uint16 pix;
+		size /= 2;
+		do {
+			pix = *(Uint16*)line;
+			/* assuming 5:6:5 RGB channels for 16-bit values */
+			pix = ((pix & 0xf000) >> 1) | ((pix & 0x7c0) >> 1) | (pix & 0x1e >> 1);
+			*(Uint16*)next = pix;
+			line += 2;
+			next += 2;
+		}
+		while (--size);
 	}
-	return line + 2 * size;
+	else	/* palettized 8-bit? */
+		next += size;
+	return next;
 }
 
 /* lookup tables and conversion macros */
-- 
2.20.1


--------------358B010A8D6093911DF4EDBB--



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/