[PATCH 2/2] Improve doubled TV monitor mode for 32-bit output

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


Having every other line black makes the screen too dark, use half the
intensity instead. This is done only for 32-bit mode as it's simple
there.

(16-bit mode would have required extra lookup table or bit-twiddling,
and 16-bit mode is used only when absolutely needed for speed, so I
didn't want to slow that down.)

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                 | 29 ++++++++++++++++++++++++++---
 9 files changed, 34 insertions(+), 11 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 d3ef4be4..42d16d56 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1607,14 +1607,37 @@ static void Convert_StartFrame(void)
  *
  * 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;
 	}
-	return line + 2 * size;
+	/* TV-mode */
+	else if (bits == 32)
+	{
+		size /= 4;
+		do {
+			/* duplicate line pixels get half the intensity of
+			 * above line's pixels R/G/B channels (A is skipped)
+			 */
+			*next++ = *line++ >> 1;
+			*next++ = *line++ >> 1;
+			*next++ = *line++ >> 1;
+			next++; line++;
+		}
+		while (--size);
+	}
+	else
+		/* halving intensity would require too much work for
+		 * 16-bit 5:6:5 RGB-values, and as 16-bit is used only
+		 * when speed is crucial, leave alternate lines black
+		 * in TV-mode
+		 */
+		next += size;
+	return next;
 }
 
 /* lookup tables and conversion macros */
-- 
2.20.1


--------------6A7DF27EC3B53E20A87C360F
Content-Type: text/x-patch;
 name="0001-Simplify-low-med-rez-screen-doubling-code.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0001-Simplify-low-med-rez-screen-doubling-code.patch"



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