Challenging AI to Build a UEFI Brick-Breaker Game: A Hands-On Low-Level Development Report

    This hands-on report documents an attempt to get AI to build a graphical brick-breaker game that runs in the UEFI Shell with Chinese text support. It breaks the work into verifiable stages—environment setup, project skeleton, GOP graphics initialization, non-blocking keyboard polling, bitmap font rendering, game logic, and full integration—and explains where AI accelerates development and where human oversight is mandatory. Readers will learn the core UEFI protocols and interfaces (EFI_SYSTEM_TABLE, EFI_GRAPHICS_OUTPUT_PROTOCOL, input protocols), common AI failure patterns such as misuse of OS-level APIs, and a five-point engineering checklist for keeping AI productive in firmware work.

    1. The Verdict First: What AI Can and Cannot Do

    Many developers ask: How do you implement Chinese text display in UEFI? What mistakes does AI commonly make with low-level code? Can AI generate a bootable .efi game from scratch? This hands-on session offers a clear answer: AI can significantly speed up structural scaffolding, the graphics loop, collision detection, and pseudocode generation for a UEFI program. But without firmware context, protocol details, and feedback from real hardware, it easily produces solutions that “look reasonable but cannot actually run.”

    The goal of this challenge was therefore neither to glorify AI nor to dismiss it, but to place AI inside a real engineering workflow and observe its behavior. Under deliberately constrained conditions—a basic IDE on Windows, an empty code baseline, and minimal human intervention—I asked AI to help build a graphical brick-breaker game that runs in the UEFI Shell and supports Chinese display. The focus is not “can AI do it in one shot,” but “which parts require human sign-off and which parts can be handed to AI for rapid generation.”

    2. Challenge Setup: Environment, Goals, and Safety Boundaries

    The session used a deliberately strict setup:

    • Minimal environment: only a basic IDE, with no third-party graphics library, font library, or game engine preinstalled;
    • Zero code baseline: an empty local repository, with no hand-written initialization code up front;
    • Weak human intervention: the human supplies only the goal, constraints, and verification method, rather than guiding every function step by step;
    • Clear objective: run a graphical brick-breaker in the UEFI Shell and display a Chinese title, score, or prompt messages.

    Before starting, however, the environment prerequisites and risks must be stated. A UEFI program is not an ordinary Windows program; it runs in the boot environment provided by firmware and depends on specific protocols and system tables. If the motherboard firmware does not support the graphics output protocol, the program cannot draw anything; if the UEFI Shell is unavailable, you cannot run interactive tests. So before testing, confirm the following:

    1. The motherboard supports UEFI boot and can enter the UEFI Shell;
    2. The firmware provides EFI_GRAPHICS_OUTPUT_PROTOCOL (the graphics output protocol);
    3. The test machine is a virtual machine or a spare device, and important data is already backed up;
    4. If Secure Boot must be disabled for testing, do so in a controlled environment to avoid affecting a production machine;
    5. Modifying USB boot entries or firmware settings may affect boot safety, so keep the original firmware settings or a rollback plan.

    The USB directory can follow a structure like this:

    1. USB:\
    2. ├─ EFI\
    3. │ ├─ BOOT\
    4. │ │ └─ BOOTX64.EFI # optional, for automatic boot testing
    5. │ └─ BRICK\
    6. │ └─ BrickGame.efi # the brick-breaker program under test
    7. └─ LOG\
    8. └─ brickgame.log # optional, for recording screen logs

    After entering the UEFI Shell, you can run the program through a path like this:

    1. fs0:
    2. cd EFI\BRICK
    3. BrickGame.efi

    If the firmware automatically maps the USB drive to a different drive letter, use commands such as map or fs-related commands to inspect the devices. The point here is not to memorize commands, but to make AI understand that program output, input, and display all happen in a bare boot environment. You cannot assume an OS file system, a graphics API, or a font service exists.

    3. Why Brick-Breaker: A Litmus Test for Low-Level Skills

    Brick-breaker was chosen not because it is “simple,” but because it compresses common low-level development skills into a small, verifiable game. Compared with register initialization, boot flow adaptation, or porting a firmware protocol stack, the logic boundaries of brick-breaker are clearer, which makes AI’s generation quality easier to observe.

    Here is a comparison between common low-level tasks and brick-breaker:

    Task type Core difficulty Verifiability AI focus
    Boot flow adaptation Stage transitions, boot services, memory layout Requires hardware and firmware support Generate frameworks, outline the flow
    Register initialization Chip manuals, timing, hardware differences Strongly hardware-dependent Generate pseudocode and parameter tables
    Graphics display Frame buffer, pixel format, screen resolution Can see results directly Generate GOP init and drawing logic
    Input handling Key protocol, polling, event waiting Verifiable with key presses Generate keyboard scan code
    Brick-breaker game Rendering, collision, state machine, Chinese display Fully runnable and verifiable Generate game loop and module structure

    Brick-breaker is thus like a “low-level capability bundle”: it requires the program to manage graphics output, keyboard input, timing control, collision detection, and Chinese bitmap display, yet unlike a full firmware module, it does not depend on large numbers of hardware registers. That makes it a suitable vehicle for observing AI’s programming ability.

    4. Core UEFI Development Difficulties: Ground Everything in Protocols and Interfaces

    If you stop at the level of “AI can write code,” the exercise quickly becomes empty talk. To make AI produce verifiable output, the difficulties must be reduced to the protocol layer, the interface layer, and the data structure layer.

    4.1 Executables and Boot Services

    A UEFI program is typically a .efi file in PE/COFF format. It runs in the boot environment provided by firmware, and its entry function usually looks like this:

    1. EFI_STATUS
    2. EFIAPI
    3. UefiMain (
    4. IN EFI_HANDLE ImageHandle,
    5. IN EFI_SYSTEM_TABLE *SystemTable
    6. )

    The program relies on interfaces within EFI_SYSTEM_TABLE, such as boot services, console output, and console input. Once ExitBootServices is called, many boot services become unavailable. Therefore, an interactive program like brick-breaker typically completes initialization, its main loop, and exit while boot services are still available.

    4.2 Graphics Output: GOP and the Frame Buffer

    The key protocol for UEFI graphics output is EFI_GRAPHICS_OUTPUT_PROTOCOL, abbreviated GOP. The program needs to:

    1. LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, &gop);
    2. gop->SetMode(gop, 1);

    SetMode switches the graphics mode. Different firmware supports different modes—some support 800x600, some 1024x768, and some may support even higher resolutions. After initialization, the program can read Mode->FrameBufferBase and Mode->FrameBufferSize and then operate on the frame buffer directly.

    Common pixel formats include 32-bit BGR or BGRA. There are no high-level DrawRect, DrawImage, or DrawText interfaces; every draw operation must become a pixel write. Filling a rectangle, for example, means computing the buffer address that corresponds to a screen coordinate and then writing a color value. If AI simply applies a Windows GDI mindset, it often generates APIs that do not exist.

    4.3 Keyboard Input: Polling, Not Interrupts

    Under an operating system, the keyboard usually has a driver, an event queue, and an interrupt mechanism. But in the simple UEFI input environment, the program generally must actively query for keys. The core interface may come from the Simple Text Input Protocol or the extended input protocol. The program can use ReadKeyStroke to obtain scan codes and Unicode characters, or use WaitForEvent to wait for an input event.

    Brick-breaker needs to respond in real time to arrow keys, the space bar, or an exit key. If input blocks, the screen stutters; if polling is too slow, key presses may be lost. A common approach is to read keys non-blockingly in the main loop, then update the game state, then draw the frame. AI’s frequent mistake here is writing input as synchronous blocking, or assuming an OS-level event loop exists.

    4.4 Chinese Display: Bitmap Font Mapping

    Chinese display in UEFI is one of the key difficulties of this challenge. An operating system usually has a mature font engine, but the UEFI environment has no complete Unicode font rendering service. To display Chinese, you typically need to embed your own bitmap font.

    The basic flow is as follows:

    1. Input string
    2. ↓
    3. Convert to Unicode or a custom encoding
    4. ↓
    5. Look up the bitmap font index by encoding
    6. ↓
    7. Extract a 16x16 or 12x12 bitmap glyph
    8. ↓
    9. Write pixel-by-pixel to the GOP frame buffer
    10. ↓
    11. Chinese displayed on screen

    For example, you can first prepare a font16x16.h that stores bitmap data for a small set of Chinese characters. The program encodes strings such as “Score,” “Paused,” and “Game Over,” looks them up in the table, and then reads the bitmap row by row. For a 16x16 font, each glyph usually occupies 32 bytes; each byte represents 8 pixels in a row, and each bit determines whether that pixel is lit.

    This is where AI most often deviates: it may generate a DrawString function or assume the system has a font module; it may also write Unicode handling that is overly complete while ignoring the implementation cost in the UEFI environment. In practice, the safer approach is to have AI generate a minimal “font table + bitmap drawing function” solution rather than pursuing a complete character set.

    4.5 Timing and Frame-Rate Control

    Without OS scheduling, frame-rate control must rely on the firmware time service or a delay interface. A simple option is to use Stall, sleeping roughly 16 milliseconds per frame to approach 60 FPS. A more rigorous approach is to read a timestamp, compute the actual time spent on each frame, and then add a delay for the remaining time.

    If AI generates only an empty while(1) loop, the screen will flicker quickly or CPU usage will behave abnormally. So the human needs to add a rule: every frame must include four phases—input, update, draw, and delay—and specify a target frame rate.

    5. The Complete AI Collaboration Workflow: A Reproducible Stage Table

    To make AI a true “implementation assistant” rather than an “inspiration generator,” this session broke the process into verifiable stages. Each stage has an input, AI output, human correction, and verification result.

    Stage Input to AI AI output Human correction Verification result
    Environment review Goal, firmware limits, no OS Engineering constraint list Add GOP, Secure Boot, backup requirements Test boundaries clarified
    Project skeleton Directory structure, entry function File list and initialization framework Remove unavailable dependencies Entry point recognized
    Graphics init GOP protocol name, mode setting Init and clear-screen code Add frame buffer write method Solid color or color bars appear
    Keyboard input Polling requirement, non-blocking Key read function Fix the blocking issue Arrow keys can be recorded
    Chinese display Bitmap font, pixel mapping Font lookup and drawing function Add font data Chinese displayed on screen
    Game logic Bricks, paddle, ball, collision State machine and collision detection Adjust boundaries and coordinates Ball bounces, bricks disappear
    Full integration Log fields, frame rate Complete main loop Add exit and exception handling Game runs and exits

    AI is best at quickly generating scaffolding when the structure is clear and constraints are well defined. Asking it for “the entry function, initialization order, main loop pseudocode, and brick collision detection” usually yields high quality. But when the task involves “how firmware maps fonts,” “how to write to the GOP frame buffer address,” or “how to make input non-blocking,” AI often needs the human to supply domain constraints.

    5.1 Context File Fields

    To reduce directional errors, it helps to give AI a project context file. The fields can include:

    1. Goal: Run a graphical brick-breaker in the UEFI Shell with Chinese display.
    2. Architecture: X64.
    3. Environment: No OS, no third-party graphics library.
    4. Graphics protocol: EFI_GRAPHICS_OUTPUT_PROTOCOL.
    5. Input protocol: EFI_SIMPLE_TEXT_INPUT_PROTOCOL or the extended input protocol.
    6. Display requirement: Prefer 16x16 bitmap Chinese; the font can be generated offline.
    7. Prohibitions: No Windows API, no stdlib file system, no full graphics library.
    8. Verification: Can draw color bars, respond to keys, display Chinese, and exit.
    9. Risk requirements: Do not modify a production machine's boot entries; provide notes on backup and on scenarios where disabling Secure Boot is applicable.

    A context like this is far more valuable than a single sentence such as “write a UEFI brick-breaker.” It tells AI where the boundaries are and makes human review easier.

    Here is a directory layout that suits both AI generation and human maintenance:

    1. BrickGame/
    2. ├─ BrickGame.inf
    3. ├─ BrickGame.c
    4. ├─ gfx.c
    5. ├─ input.c
    6. ├─ game.c
    7. ├─ font16x16.h
    8. └─ README.md

    Responsibilities of each file:

    • BrickGame.c: entry function and lifecycle management;
    • gfx.c: GOP initialization, clear screen, draw rectangles, draw bitmaps;
    • input.c: key polling and direction control;
    • game.c: bricks, ball, paddle, collision, and scoring;
    • font16x16.h: Chinese glyph bitmaps;
    • README.md: build command, run path, and known issues.

    5.3 Entry Pseudocode

    You can give AI an entry framework like this as a starting point:

    1. EFI_STATUS
    2. EFIAPI
    3. UefiMain (
    4. IN EFI_HANDLE ImageHandle,
    5. IN EFI_SYSTEM_TABLE *SystemTable
    6. )
    7. {
    8. SystemTable = SystemTable;
    9. if (!InitGraphics()) {
    10. Print(L"GOP not found or mode failed\n");
    11. return EFI_UNSUPPORTED;
    12. }
    13. InitInput();
    14. InitGame();
    15. while (!GameShouldExit()) {
    16. PollInput();
    17. UpdateGame();
    18. ClearScreen();
    19. DrawBricks();
    20. DrawPaddle();
    21. DrawBall();
    22. DrawChineseText();
    23. Stall(16666); // ~60 FPS
    24. }
    25. RestoreGraphicsIfNeeded();
    26. return EFI_SUCCESS;
    27. }

    This is not the final code; it exists so AI can continue extending on the right level of abstraction. AI can fill in functions such as PollInput and DrawBricks, but the human must check whether it has called functions that do not exist in the UEFI environment.

    5.4 Build, Run, and Debug Logging

    If you use an EDK2 project, a typical build command can be written as:

    1. build -p BrickGame.dsc -a X64 -b DEBUG

    After building, copy BrickGame.efi to the USB drive:

    1. USB:\EFI\BRICK\BrickGame.efi

    Run it in the UEFI Shell:

    1. fs0:
    2. cd EFI\BRICK
    3. BrickGame.efi

    For debugging, it is best to have the program emit minimal logs, for example:

    1. Print(L"GOP_OK\n");
    2. Print(L"MODE=%d %dx%d\n", mode, width, height);
    3. Print(L"KEY_DOWN scan=%x char=%x\n", scan, unicode);
    4. Print(L"FPS_EST=%d\n", fps);

    The logs do not need to be exhaustive, but they should be enough to answer a few questions: Was GOP found? Did the mode get set successfully? Were key presses read? Were the Chinese bitmap glyphs found? Is the program stuck in the input or drawing phase?

    6. Common AI Errors and Human Correction Points

    In practice, AI’s errors are not random; they follow fixed patterns. Common ones include:

    1. Misusing OS interfaces: generating Windows APIs such as CreateWindow, DrawText, and GetAsyncKeyState;
    2. Assuming a full font library exists: calling a Unicode rendering service that does not exist;
    3. Blocking input: using a wait-for-event call that freezes the screen;
    4. Missing frame-rate control: the main loop has no delay or does not compute frame time;
    5. Hard-coding the graphics mode: not selecting a supported resolution based on the firmware;
    6. Out-of-bounds coordinates: bricks or text extend beyond the screen, causing abnormal display;
    7. Incomplete exit logic: not restoring the original graphics mode, or not releasing resources that were used.

    The core of human correction is not to write the full code for AI, but to supply the domain constraints it lacks. For example, when AI generates a font function, the human should stress: “There is no OS font interface; you can only use an offline bitmap table and draw it pixel by pixel.” When AI generates an input function, the human should stress: “Input must not block the main loop; it must support non-blocking polling.”

    7. The Key Efficiency Strategy: Put AI Inside an Engineering Loop

    This session shows that AI’s efficiency gains in low-level development do not depend on a single prompt, but on an engineering loop. It can be summarized in five checks:

    • Environment constraints: Is the UEFI architecture, firmware capability, and boot method clearly stated?
    • Protocol limits: Are GOP, the input protocol, and the boot service lifecycle explained?
    • Font and resources: Are the bitmap font, coordinate range, and color format provided?
    • Verification commands: Is there a working build, copy, run, and logging method?
    • Rollback plan: Are firmware settings preserved, is the test machine backed up, and is recoverable boot media available?

    When the context, protocol constraints, and verification loop are fairly complete, AI can significantly reduce scaffolding time and improve the generation efficiency of general algorithm modules. But without feedback from a real environment, AI’s output may still remain at the stage of “syntactically correct, logically sound, but failing to run.” So a more accurate statement is this: once the workflow loop is well established, AI can improve low-level development efficiency and reduce trial-and-error cost—not that it unconditionally amplifies productivity in every step.

    8. Conclusion: Capability Boundaries Depend on How You Use It

    This UEFI brick-breaker exercise shows that AI is neither helpless in low-level development nor a simple all-purpose tool. Its value lies in structured scaffolding, pseudocode expansion, general algorithm generation, and rapid trial and error; its limitations lie in hardware details, firmware protocols, platform differences, and gaps in domain knowledge.

    It is worth stressing that this conclusion comes from a single practice case. Different firmware, different compilers, different CPU architectures, different graphics modes—and even different USB-and-motherboard combinations—can all lead to different results. Therefore, developers should not treat one success as a general rule, nor blame one failure on AI itself.

    A more reasonable approach is to treat AI as an implementation assistant that needs constraints and feedback. Give it clear context and let it generate the skeleton; give it real protocols and let it complete the interfaces; give it a runnable environment and let it accept verification; and at key checkpoints, have humans review the core logic, security impact, and platform adaptation. Only by viewing AI’s strengths and weaknesses rationally can it truly serve low-level development rather than create new uncertainty.