Monorepo for Aesthetic.Computer aesthetic.computer
at main 38 lines 1.2 kB view raw
1#include <efi.h> 2#include <efilib.h> 3 4EFI_STATUS 5EFIAPI 6efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { 7 InitializeLib(ImageHandle, SystemTable); 8 EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; 9 EFI_STATUS status; 10 11 // Locate the graphics output protocol 12 status = uefi_call_wrapper(BS->LocateProtocol, 3, &GraphicsOutputProtocol, NULL, (void **)&gop); 13 if (EFI_ERROR(status)) { 14 Print(L"Unable to locate GOP\n"); 15 return status; 16 } 17 18 // Assume the display is at least 200px tall and wide for simplicity 19 UINTN line_length = 200; 20 for (UINTN i = 0; i < line_length; i++) { 21 // Calculate the position to set the pixel 22 UINTN x = i; 23 UINTN y = i; 24 UINT32 color = 0x00FFFF00; // Yellow in RGB reserved format 25 26 // Draw the pixel 27 UINTN pos = x + (y * gop->Mode->Info->PixelsPerScanLine); 28 ((UINT32 *)gop->Mode->FrameBufferBase)[pos] = color; 29 } 30 31 // Wait for key press before exiting 32 SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE); 33 EFI_INPUT_KEY Key; 34 while ((SystemTable->ConIn->ReadKeyStroke(SystemTable->ConIn, &Key)) == EFI_NOT_READY); 35 36 return EFI_SUCCESS; 37} 38