From 93e98772255e043d3341adcb6cb1e4f1463bc117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 22 Dec 2019 14:54:33 +0100 Subject: [PATCH] [BOOTVID] Factor out the common code that is used before setting pixels. --- drivers/base/bootvid/i386/vga.c | 49 ++++++++++++--------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/drivers/base/bootvid/i386/vga.c b/drivers/base/bootvid/i386/vga.c index 1c17c806cc1..2914200f246 100644 --- a/drivers/base/bootvid/i386/vga.c +++ b/drivers/base/bootvid/i386/vga.c @@ -87,6 +87,19 @@ ReadWriteMode(IN UCHAR Mode) __outpb(VGA_BASE_IO_PORT + GRAPH_DATA_PORT, Mode | Value); } +static VOID +PrepareForSetPixel(VOID) +{ + /* Switch to mode 10 */ + ReadWriteMode(10); + + /* Clear the 4 planes (we're already in unchained mode here) */ + __outpw(VGA_BASE_IO_PORT + SEQ_ADDRESS_PORT, 0x0F02); + + /* Select the color don't care register */ + __outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7); +} + FORCEINLINE VOID SetPixel(IN ULONG Left, @@ -133,14 +146,7 @@ DisplayCharacter(IN CHAR Character, ULONG Height; UCHAR Shift; - /* Switch to mode 10 */ - ReadWriteMode(10); - - /* Clear the 4 planes (we're already in unchained mode here) */ - __outpw(VGA_BASE_IO_PORT + SEQ_ADDRESS_PORT, 0x0F02); - - /* Select the color don't care register */ - __outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7); + PrepareForSetPixel(); /* Calculate shift */ Shift = Left & 7; @@ -427,14 +433,7 @@ BitBlt(IN ULONG Left, return; } - /* Switch to mode 10 */ - ReadWriteMode(10); - - /* Clear the 4 planes (we're already in unchained mode here) */ - __outpw(VGA_BASE_IO_PORT + SEQ_ADDRESS_PORT, 0x0F02); - - /* Select the color don't care register */ - __outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7); + PrepareForSetPixel(); /* 4bpp blitting */ for (dy = Top; dy < Bottom; ++dy) @@ -473,14 +472,7 @@ RleBitBlt(IN ULONG Left, ULONG i, j; ULONG Code; - /* Switch to mode 10 */ - ReadWriteMode(10); - - /* Clear the 4 planes (we're already in unchained mode here) */ - __outpw(VGA_BASE_IO_PORT + SEQ_ADDRESS_PORT, 0x0F02); - - /* Select the color don't care register */ - __outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7); + PrepareForSetPixel(); /* Set Y height and current X value and start loop */ YDelta = Top + Height - 1; @@ -1034,14 +1026,7 @@ VidSolidColorFill(IN ULONG Left, /* If there is no distance, then combine the right and left masks */ if (!Distance) lMask &= rMask; - /* Switch to mode 10 */ - ReadWriteMode(10); - - /* Clear the 4 planes (we're already in unchained mode here) */ - __outpw(VGA_BASE_IO_PORT + SEQ_ADDRESS_PORT, 0x0F02); - - /* Select the color don't care register */ - __outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7); + PrepareForSetPixel(); /* Calculate pixel position for the read */ Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + LeftOffset);