UEFI Shell Breakout Game: Testing an AI Coding Tool in Low-Level Development

    This article describes using an AI coding tool to build a Breakout game that runs in the UEFI Shell with Chinese display support. It breaks the project into graphics output, non-blocking keyboard input, bitmap font rendering, and collision detection, then evaluates the tool’s strengths and limitations in firmware-level development. Readers get a practical view of where such a tool helps and where human domain knowledge remains essential.

    1. Why This Test Project

    When evaluating the real capability of an AI coding tool, simple script tasks or web demos often fail to reveal the tool’s limits. I prefer to use a small project that has some technical depth but is also clearly structured. Breakout is the litmus test I have used repeatedly over the years.

    There are three reasons for choosing it:

    1. Complete structure: A Breakout game includes graphics rendering, user input handling, collision detection, and state management (start, in progress, end). It is small but complete.
    2. Clear and verifiable goals: Whether the game runs, whether bricks can be broken, and whether the ball speed is reasonable are all objective criteria. There is no subjective debate about whether the “effect is good.”
    3. A non-trivial tech stack: The target I set for this project was fairly challenging. It was not an ordinary desktop game, but a graphics program that runs in the UEFI Shell and supports Chinese display. In simple terms, it is a program that can be copied to a USB drive, plugged into a computer, and run after entering the BIOS Shell.

    This means it cannot rely on an operating system, call conventional graphics libraries, or use common font-rendering approaches. Everything has to be built in a bare firmware environment. These constraints make it an excellent test of an AI coding tool’s knowledge depth and problem-decomposition ability.

    2. Breaking Down the Technical Challenges

    Before formally involving the AI tool, I broke the task into several subproblems and observed the tool’s performance on each one.

    1. Graphics Output in UEFI

    Graphics output in UEFI is based on the Graphics Output Protocol. This protocol provides the Blt (Block Transfer) operation interface, which can perform basic graphics operations such as pixel filling and block transfers. Developers need to locate the protocol through boot services during the system startup phase, then get display resolution information and draw on it.

    Illustrative code:

    1. EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
    2. gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid,
    3. NULL, (VOID **)&Gop);
    4. // Get current mode information
    5. EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info = Gop->Mode->Info;
    6. // Draw a filled rectangle (for example, a brick)
    7. Gop->Blt(Gop, &FillColor,
    8. EfiBltBufferToVideo, 0, 0,
    9. X, Y, BrickWidth, BrickHeight, 0);

    I was satisfied with the AI coding tool’s performance in this part. When I described “how to draw a rectangle under UEFI,” it correctly provided the complete chain for protocol location, mode query, and Blt calls. It even reminded me to pay attention to pixel format differences (RGB versus BGR) across display modes. This is a typical pitfall that is easy to overlook but can cause abnormal color display.

    2. Non-blocking Keyboard Input

    A game needs to respond to key presses in real time, but standard input reading under UEFI is blocking by default. The correct approach is to use a non-blocking read function:

    1. EFI_INPUT_KEY Key;
    2. if (gST->ConIn->ReadKeyStroke(gST->ConIn, &Key)
    3. == EFI_SUCCESS) {
    4. // Handle left/right movement
    5. }

    Here, the tool not only gave the correct API call but also proactively pointed out that “polling should be paired with an appropriate delay; otherwise, the ball speed may fluctuate with CPU performance.” This sensitivity to real-time behavior exceeded my expectations.

    3. Chinese Display: The Biggest Challenge

    The UEFI Shell’s default character output has very limited Chinese support and usually can display only single-byte character sets. To support Chinese, I had to build a font-rendering system from scratch:

    • Bitmap font approach: Embed 16×16 bitmap data for common Chinese characters (such as “Score,” “Start,” and “Game Over”) into the program. During drawing, check each bit to decide whether to fill a pixel. This is the most controllable and lightweight approach.
    • Double-byte encoding handling: Chinese characters occupy two bytes in common encodings. The program needs to correctly split strings and retrieve bitmap data by looking it up by index.

    In the prompt, I asked the tool to generate a bitmap font structure and rendering functions. The framework code it produced was structurally reasonable: it defined a structure with glyph width, height, and a bitmap array, and implemented drawing logic that scans row by row, pixel by pixel. However, for the bitmap data of specific Chinese characters, the tool explicitly stated that it could not generate accurate glyph data out of thin air and suggested extracting it from publicly available bitmap font resources. This showed an honest awareness of its capability boundary: it preferred to ask for manual supplementation rather than fabricate data that looked correct but was wrong. This is particularly valuable in an AI coding tool.

    4. Collision Detection and Game State

    Collision detection is a pure algorithm problem, and the tool was stable:

    • Ball and paddle: determine whether the ball’s Y coordinate has reached the paddle’s row and whether its X coordinate falls within the paddle’s range, then reverse the Y velocity.
    • Ball and bricks: iterate over surviving bricks, perform rectangle intersection tests, remove a brick on a hit, and decide the velocity reversal direction based on the collision edge (horizontal or vertical).
    • Ball and boundaries: bounce at the top and count as a failure at the bottom.

    One detail worth noting: my initial collision logic was relatively rough, and the tool proactively raised the issue that a high-speed ball could pass through a thin paddle. It suggested linear interpolation detection along the path traveled after movement. This ability to proactively identify potential defects is a key distinction between a code generator and a programming assistant.

    3. Overall Experience

    From decomposition and coding to debugging, the AI coding tool contributed about 70% of the code output, while I was mainly responsible for architecture decisions, bitmap font extraction, and debugging corrections. Overall:

    Strengths:

    • For a relatively niche but well-documented technical area like UEFI, the tool has solid knowledge and can provide the correct protocol call chain;
    • It has good problem-decomposition ability and, while understanding the overall requirement, proactively adds boundary conditions and potential defects;
    • It is honest about its capability boundary and does not fabricate data whose correctness it cannot guarantee.

    Weaknesses:

    • Parts that require real data support, such as glyph bitmaps, cannot be completed independently and still need manual intervention;
    • In long code contexts, there are occasionally inconsistent variable names, which require manual checking;
    • It underestimates the reality of limited debugging options in firmware environments. Some suggested debugging approaches depend on an OS environment and are not applicable.

    Overall conclusion: Using an AI coding tool to assist with this kind of low-level development is entirely feasible. It can significantly reduce the cost of mechanical work such as protocol calls and algorithm implementation, allowing developers to focus on architecture and difficult problems. However, developers still need sufficient domain knowledge to judge the correctness of the output. The tool is an accelerator, not a replacement. The moment the Breakout game finally ran successfully in the BIOS Shell with Chinese displayed correctly also validated the practical value of this human-machine collaboration model.