-
Notifications
You must be signed in to change notification settings - Fork 2
/
Screen.c
53 lines (43 loc) · 1.09 KB
/
Screen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "Screen.h"
static EFI_GUID graphicProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
static EFI_GRAPHICS_OUTPUT_PROTOCOL* protocol = NULL;
static UINT32 pplin;
static UINT32 width;
static UINT32 height;
EFI_STATUS
InitScreen(){
EFI_STATUS s = gBS->LocateProtocol(&graphicProtocolGuid,
NULL, (VOID**) &protocol);
if( EFI_ERROR(s) || protocol == NULL ){
return s;
}
width = protocol->Mode->Info->HorizontalResolution;
height = protocol->Mode->Info->VerticalResolution;
pplin = protocol->Mode->Info->PixelsPerScanLine;
return s;
}
VOID
DrawRect(IN UINT32 x, IN UINT32 y,
IN UINT32 width, IN UINT32 height,
IN BltPixel color)
{
BltPixel buf = color;
EFI_STATUS st = protocol->Blt(protocol, &buf, EfiBltVideoFill,
0, 0,
x, y,
width, height, 0);
if(EFI_ERROR(st)){
Print(L"Error %d drawing rectangle at (%u,%u,%u,%u)\n", st, x, y, width, height);
}
}
VOID
SetBackgroundColor(IN UINT8 r, IN UINT8 g, IN UINT8 b)
{
BltPixel background = {b, g, r, 0};
DrawRect(0, 0, width, height, background);
}
UINT32
ScreenGetWidth(VOID)
{
return width;
}