From 817de39e6095f46d4d4d4e46a73ac848c0347433 Mon Sep 17 00:00:00 2001 From: Nikita <102851041+HyperNiki@users.noreply.github.com> Date: Tue, 17 May 2022 22:29:07 +0300 Subject: implement the chess board test --- UefiMonitorTest/UefiMonitorTestStrings.uni | 10 ++++ UefiMonitorTest/tests/ChessBoard.c | 92 ++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/UefiMonitorTest/UefiMonitorTestStrings.uni b/UefiMonitorTest/UefiMonitorTestStrings.uni index 60c519c..c99a949 100644 --- a/UefiMonitorTest/UefiMonitorTestStrings.uni +++ b/UefiMonitorTest/UefiMonitorTestStrings.uni @@ -106,3 +106,13 @@ "shouldn't have any colorful areas.\n" "\n" "Gray tone: %d\n" + +// Test "Chess Board" + +#string STR_CHESSBOARD_TITLE #language en-US "CHESS BOARD" + +#string STR_CHESSBOARD_MSG #language en-US "Assess the effectiveness of the monitor to display\n" + "objects with minimum and maximum brightness at the\n" + "same time.\n" + "\n" + "Side length of a square: %d\n" diff --git a/UefiMonitorTest/tests/ChessBoard.c b/UefiMonitorTest/tests/ChessBoard.c index 6b90067..7b3b976 100644 --- a/UefiMonitorTest/tests/ChessBoard.c +++ b/UefiMonitorTest/tests/ChessBoard.c @@ -1,11 +1,48 @@ +#include +#include +#include + #include "tests/ChessBoard.h" +STATIC UINT32 CurrentSideLength = 1; + VOID ChessBoardTestInit ( IN UMT_CONTEXT *Ctx ) { + UINT32 I; + UINT32 J; + enum UMT_COLORS ColorSquare; + enum UMT_COLORS FirstColorSquare; + enum UMT_COLORS TempColor; + GRAPHICS_CONTEXT *Graphics = Ctx->Graphics; + + FirstColorSquare = UMT_COLOR_WHITE; + ColorSquare = UMT_COLOR_BLACK; + + for (J = 0; J < Graphics->Height; J += CurrentSideLength) + { + TempColor = FirstColorSquare; + FirstColorSquare = ColorSquare; + ColorSquare = TempColor; + for (I = 0; I < Graphics->Width; I += CurrentSideLength) + { + PutRect (Graphics, + I, + J, + I + CurrentSideLength, + J + CurrentSideLength, + &gUmtColors[ColorSquare].Color); + + ColorSquare = ((ColorSquare == UMT_COLOR_WHITE) ? UMT_COLOR_BLACK : UMT_COLOR_WHITE); + } + } + + if (Ctx->ShowTip) { + ChessBoardTestTip (Ctx); + } } VOID @@ -21,7 +58,36 @@ ChessBoardTestTip ( IN UMT_CONTEXT *Ctx ) { + GRAPHICS_CONTEXT *Graphics; + + Graphics = Ctx->Graphics; + if (Ctx->ShowTip == FALSE) { + // Restore + ChessBoardTestInit (Ctx); + return; + } + + DrawRectWithBorder (Graphics, + 15, + Graphics->Height - 15 - 124, + 430, Graphics->Height - 15, + 3, + &gUmtColors[UMT_COLOR_WHITE].Color, + &gUmtColors[UMT_COLOR_NAVY].Color); + + DrawHiiStringF (Graphics, + 25, + Graphics->Height - 15 - 114, + &gUmtColors[UMT_COLOR_NAVY].Color, + STRING_TOKEN (STR_CHESSBOARD_TITLE), gUmtHiiHandle); + + DrawHiiStringF (Graphics, + 25, + Graphics->Height - 15 - 94, + &gUmtColors[UMT_COLOR_BLACK].Color, + STRING_TOKEN (STR_CHESSBOARD_MSG), gUmtHiiHandle, + CurrentSideLength); } VOID @@ -39,5 +105,31 @@ ChessBoardTestChangeValue ( IN INT8 ValueStep ) { + UINT32 ValueOut; + UINT32 Height; + UINT32 Width; + + Height = Ctx->Graphics->Height; + Width = Ctx->Graphics->Width; + ValueOut = CurrentSideLength + ValueStep; + + if (ValueOut == 0) { + return; + } + + while ((((Width / ValueOut) * ValueOut != Width) || + ((Height / ValueOut) * ValueOut != Height)) && + ((ValueOut < Height) && (ValueOut < Width)) && + (ValueOut > 1)) + { + ValueOut += ValueStep; + } + + if ((ValueOut >= Height) || (ValueOut >= Width)) + { + return; + } + CurrentSideLength = ValueOut; + ChessBoardTestInit (Ctx); } -- cgit v1.2.3-18-g5258