Building a Game in a Headless UEFI Shell: A Hands-On Test of LLM Coding Ability

    This article uses a single benchmark task—building a top-down tank battle game in a headless UEFI Shell environment—to compare how well large language models handle real engineering work. It documents a unified testing process, two major pitfalls (build environment setup and unclear requirements), the core rendering and game-loop techniques, and a breakdown of token consumption. The key takeaway: modern models now struggle less with complex logic and more with environment configuration and requirement clarification. Three practical practices—separating environment setup from coding, forcing the model to ask questions first, and setting a hard stop-loss limit—can noticeably improve success rates while lowering cost.

    1. Why a Firmware-Layer Game Makes a Good Benchmark

    When evaluating the coding ability of large language models, the common problem sets have become highly homogeneous: build a to-do list, implement a sorting algorithm, generate an admin dashboard. These tasks barely differentiate a model’s real engineering capability, because the training corpus is saturated with similar samples and the model can often finish by pattern matching alone.

    For this reason, I have long used the same benchmark task for side-by-side comparisons: implement a top-down classic tank battle game in a headless firmware Shell environment. The value of this task is that it stacks several difficulties together:

    • Extreme runtime environment: no operating system, no runtime, no third-party graphics library. The only graphics capability available is the firmware-provided graphics output protocol (commonly a GOP-style framebuffer interface).
    • Rendering must be hand-written: every pixel has to be computed and written by yourself, the BGRA framebuffer has to be managed manually, and double buffering and refresh timing must be controlled on your own.
    • Input relies on key scanning: keyboard events are read through a character input protocol, and the scan codes for arrow keys and function keys must be handled one by one.
    • Non-trivial logic complexity: maps, enemy spawn waves, power-ups, collision detection, and particle effects—missing any one of them turns the result into something that “looks like the game but doesn’t play like it.”

    Before this, I had already tested six domestic models with the exact same task and prompt. They showed a clear split on the single question of “can the project actually be built and run”: some completed compilation and execution smoothly, while others got stuck at the most basic environment configuration step. Now that a new generation of models has been released, I topped up and started testing right away.

    A note on not doing a China-versus-overseas comparison: my principle here is to prioritize supporting domestic models. Only when more people use them will feedback be sufficient, iteration reach the scale needed for network effects, and costs come down. This is not exclusion; it is a choice.

    2. Test Method and Unified Constraints

    To keep results comparable, all models used the same process and the same requirements description, with no targeted hints.

    The key requirements were as follows (illustrative):

    1. Create a graphics application in the current directory that runs under the firmware Shell:
    2. - Gameplay: fixed top-down map; the player controls a tank to move and shoot, destroys spawned enemy tanks, and protects the home base
    3. - Terrain: brick walls can be destroyed by bullets; steel walls cannot
    4. - Power-ups: invincibility, armor-piercing rounds, extra lives, and more
    5. - Win condition: survive all waves
    6. - Graphics output: use the framebuffer of the firmware graphics output protocol
    7. - Runtime: a pure software firmware application, debugged in a virtualized environment
    8. - No sound needed

    The process was fixed at four steps: generate the project documentation → set up the build environment → compile and link → run and validate in a virtualized environment.

    The acceptance criteria were also clear: a working welcome screen, 640×480 resolution, a stable 30 FPS, eight maps, four enemy types, five power-ups, and working particle effects. All of them had to be met to pass.

    3. The First Pitfall: The Build Environment Is Itself a Dividing Line

    The results were revealing: most models did not lose on game logic, but on the build environment.

    The path I first chose was the emulator project package common in the firmware engineering community. Its idea is to compile firmware modules into an executable on the host operating system, eliminating hardware dependencies. In theory this is the least troublesome approach; in practice it turned out to be a deep pit:

    1. The package is sensitive to toolchain versions—any mismatch in the compiler, linker, or library paths causes failure;
    2. It requires modifying project description files and firmware description files, involving module lists, dependency libraries, and GUID/protocol dependency declarations;
    3. Error messages are highly indirect—a single missing dependency often shows up as a pile of seemingly unrelated linker errors.

    The new-generation model struggled here as well: it repeatedly modified project configuration, adjusted dependency declarations, and retried compilation. Tokens kept being consumed, but the errors did not budge. When the cost accumulated to about one-third of the budget with no progress, I judged that continuing was a sunk cost, cut losses decisively, and prompted the model to switch to debugging directly in a virtualized environment:

    1. Stop trying to compile the emulator project. Switch to loading and debugging a hardened firmware image in a virtual machine.

    This decision immediately changed the situation. There is a piece of engineering wisdom worth remembering here: when a model fails three or more times in a row on one direction, do not expect it to “figure it out” on its own—a human should provide a directional switch. A model’s self-correction ability is mainly at the local code level; for architecture-level decisions like “take a different path,” it tends to be overly conservative.

    4. The Second Pitfall: Writing Code Before Clarifying Requirements

    After switching to the virtualization approach, real coding ability began to show. The second problem to surface was requirement ambiguity.

    In the original requirement, the phrase “classic tank battle game” was understood very differently across models: some built a single fixed map, some made enemies move randomly without shooting, some ignored the core rule that losing the base means defeat, and some simply omitted collision detection, causing tanks to pass through walls.

    My corrective prompt was:

    1. Don't write code yet. List the rule points you are unsure about, confirm them with me one by one, and start only after confirmation.

    The effect was immediate. The model listed more than a dozen items to confirm in one go: map size and tile size, the number of enemies spawned and the maximum number present at once, power-up drop probability, the effective duration of armor-piercing rounds, behavior after the base is destroyed, the frame-rate control method, and so on. After confirmation, the proportion of code that came together on the first try increased markedly.

    This confirms a counterintuitive conclusion: on complex tasks, “letting the model ask first” is more effective than “writing a more detailed prompt”. Developers themselves often cannot articulate every detail, and a model proactively surfacing ambiguity points is effectively doing a requirements review for you.

    5. Rendering and the Main Loop: A Breakdown of Key Techniques

    What ultimately made the game run came down to the implementation quality of two parts: rendering and the main loop.

    Direct framebuffer writes. The firmware graphics output protocol provides a linear framebuffer, so you must compute the offset yourself as y * width * 4 + x * 4 and write pixels:

    1. static VOID PutPixel(UINT32 X, UINT32 Y, UINT32 Color)
    2. {
    3. UINT8 *Base = (UINT8 *)gFrameBuffer;
    4. UINT32 Offset = (Y * gWidth + X) * 4;
    5. Base[Offset + 0] = (UINT8)(Color); // B
    6. Base[Offset + 1] = (UINT8)(Color >> 8); // G
    7. Base[Offset + 2] = (UINT8)(Color >> 16); // R
    8. Base[Offset + 3] = 0; // Reserved
    9. }

    Offscreen buffer and full-frame refresh. Drawing directly on the display buffer produces tearing and flicker. The standard approach is to allocate a block of memory as a back buffer, copy the whole block after drawing, or refresh by dirty rectangles.

    Fixed-timestep main loop. To keep speed consistent across machines, logic updates and rendering are decoupled using a fixed-timestep accumulator:

    1. while (Running) {
    2. Accumulator += ElapsedMs();
    3. while (Accumulator >= STEP_MS) {
    4. Update(); // Logic update, fixed at 33ms
    5. Accumulator -= STEP_MS;
    6. }
    7. Render(); // Render the current state
    8. WaitForTick(1); // Yield the CPU to avoid busy spinning
    9. }

    Collision detection. With a tile map, a bounding box plus tile indexing is enough. Note that the collision matrix for the four object categories—player, enemy, bullet, and base—must be defined separately to avoid logic errors such as “enemy bullets hitting enemies.”

    6. Context Management and Cost Control

    The token consumption distribution in this test was quite representative: environment configuration consumed about one-third, requirement clarification and code generation about half, and debugging and error fixing about one-sixth. Here are three actionable recommendations:

    1. Isolate environment-related tasks. Complete build environment setup in a separate session, and enter coding only after confirming it works, to avoid error logs polluting the context.
    2. Carry conventions in documents rather than conversation. Have the model first produce a project documentation file, then treat that document as the single source of truth for all subsequent sessions, which significantly reduces repeated explanation.
    3. Set a hard stop-loss line. Define a budget cap for a single task, and switch approaches once it is exceeded instead of continuing to ask. The model will not proactively tell you “this path won’t work.”

    7. Conclusion

    The core judgment from this test is: for real engineering tasks, the weakness of the new generation of models has shifted from “not being able to write complex logic” to “not being able to handle the environment” and “not clarifying requirements”. The implementation quality of the game itself generally passed, and the split occurred mainly at two points: build configuration and requirement understanding.

    The takeaway for developers is that getting results from AI coding tools does not depend on longer prompts, but on three things: decoupling environment from coding, forcing the model to clarify ambiguity first, and setting a stop-loss point for failing directions. Do these three, and the success rate of the same model on the same task will improve noticeably, while costs actually go down.