Building a Graphical Breakout Game in BIOS Shell: A Practical AI Programming Experiment

    This article uses a graphical Breakout game built for the UEFI Shell as a case study for evaluating AI coding in a bare-metal firmware environment. With no runtime, no standard library, and no window system, the constraints turn "can the model autocomplete code?" into "can the model complete a full engineering loop on its own?" It walks through how to control experiment variables, how to shift the developer's focus from writing code to maintaining context and reviewing results, common solutions for framebuffer graphics, Chinese bitmap-font rendering, input polling, and fixed-timestep physics, and a five-dimension framework for judging real AI capability in low-level development.

    1. Why Choose the BIOS Environment as a Testbed for AI Programming

    Evaluating AI programming at the application layer tends to produce a “looks good” verdict: the frameworks are mature, the documentation is complete, and dependencies are readily available. Even when a model’s reasoning drifts slightly, the surrounding ecosystem absorbs the mistake.

    Move the test down to the bare-metal firmware level and the situation changes completely. There is no runtime, no standard library, and no ready-made window system. Even “print a line of text” has to be written by hand.

    The constraints in the original experiment were deliberately harsh:

    • The host machine keeps only a basic development kit, with no auxiliary tools preinstalled.
    • The local codebase is empty, and the human writes no implementation code.
    • No line-by-line expert guidance is provided. The model handles design, coding, and debugging on its own.

    The target was a graphical Breakout game that launches directly under the firmware Shell, supports Chinese display, needs no sound, and runs simply by copying it to a USB drive and plugging the drive in.

    The value of these constraints is that they raise the bar from “can the model complete code?” to “can the model independently close the entire engineering loop?” Requirement clarification, module partitioning, interface design, error localization, and iterative verification are all carried by the AI. For BIOS work, where creative programming and portability development coexist, this end-to-end capability is more informative than the quality of any single code artifact.

    2. Experiment Design: Keep the Variables to a Minimum

    The most common mistake in an evaluation is having too many variables. To avoid this, three kinds of variables are held fixed.

    • Task variable: Breakout has a clear structure and complete logic. It covers the core elements of graphics rendering, user input, collision detection, and main-loop timing, and it already has reference experience on Web and mobile, which makes it easy to compare difficulty jumps across platforms.
    • Environment variable: Only a basic development kit and a text editor are used, driven through a command-line-style intelligent programming tool to avoid interference from extra plugins.
    • Cost variable: High-responsiveness flagship models are billed by usage and become noticeably expensive during long autonomous tasks. So the main experiment runs on a general-purpose model from a cloud vendor’s coding plan, and a parallel task is later run with other models, forming a reproducible comparison framework. This is much like the “family car versus sports car” tradeoff: everyday development cares more about stable output per unit cost.

    3. Rebuilding the Development Paradigm: From Writing Code to Writing Context

    In a traditional workflow, the developer spends most of their energy typing code. In AI-autonomous mode, that energy shifts to three things: defining the goal, maintaining context, and reviewing results.

    The first step is to generate a project context file. The opening instruction in the experiment was very restrained: create a project context file in Chinese, explaining that a graphical application running under the firmware Shell will be developed in this directory, that its function is Breakout, and that it has no audio. From then on, every increment to the requirements uses this file as the single source of truth, which prevents the goal from drifting over a long conversation.

    A recommended structure for the context file:

    1. # Project Goal
    2. A graphical Breakout game running under the UEFI Shell, with Chinese
    3. display support and no audio.
    4. # Runtime Constraints
    5. - No third-party runtime or standard library available
    6. - Compile using only the basic development kit
    7. - The output must be bootable directly from a USB drive
    8. # Module Breakdown
    9. 1. Startup and Shell entry
    10. 2. Graphics context and framebuffer
    11. 3. Text and glyph rendering
    12. 4. Input event polling
    13. 5. Physics and collision
    14. 6. Main loop and frame-rate control
    15. # Acceptance Criteria
    16. - Cold boot can reach the game screen
    17. - Chinese title and score display correctly
    18. - No tunneling during collisions and rebounds

    The second step is to issue instructions in stages. Asking the model to “build the entire game” all at once often leaves the architecture vague and the details out of focus. A more effective order is: first get a minimal runnable skeleton working (enter the Shell, clear the screen, draw a rectangle), then add input, then add physics, and finally add Chinese text and interface polish. At every stage, the model is asked to produce a “list of changes plus a verification method,” which turns the invisible reasoning process into a reviewable artifact.

    The third step is to establish concrete handles for manual review. Even without writing implementation code, it pays to insist on checking three things: whether memory and VRAM access goes out of bounds, whether the frame loop contains a busy-wait, and whether error codes are being ignored. These three problems carry the highest cost in a bare-metal environment and are the hardest to paper over with “just run it again.”

    4. Common Solutions to the Key Technical Challenges

    Graphics output. Firmware environments usually expose pixels through a framebuffer, so you must handle resolution detection, pixel-format identification, and rectangle filling yourself. The practical point is to abstract drawing into a very thin wrapper that exposes only two primitives, fill-rectangle and write-pixel, so that the upper-level game logic never touches a physical address directly.

    Chinese display. This is the part that differs most from Web development. A workable path is to embed a compact bitmap font that covers only the characters needed for the title, menus, and digits, then look up each glyph’s bitmap by character code and write it pixel by pixel into the framebuffer. Font size and startup time need to be balanced, so it usually makes sense to start with a “just good enough” character set and expand it as needed.

    Input handling. Input under the Shell is mostly key-event polling, which means you have to deal with debouncing, key repeat, and focus issues. In the design, input should be abstracted into four semantic actions, “move left, move right, fire, pause,” which hides low-level scancode differences and makes later porting easier.

    Collision and physics. The core of Breakout is velocity integration and bounce detection. It is better to use a fixed time step rather than counting frames, so that speed stays consistent across different refresh rates. For collision detection, first do a coarse check with axis-aligned bounding boxes, then decide the bounce axis based on the incident direction. This prevents “edge jitter” and tunneling.

    Main loop and stability. The bare-metal environment has no operating system to fall back on, so any out-of-bounds write can crash the machine outright. For this reason, keep a minimal means of observation inside the loop, for example a debug counter in a corner of the screen that shows the frame count and error code, giving the running state a way to “prove itself.”

    5. Measuring the Result: Don’t Judge Only by “Does It Run?”

    To gauge AI’s real level in low-level development, it helps to score on five dimensions:

    1. First-time success rate: whether the skeleton and the key modules compile and run on the first attempt;
    2. Autonomous debugging ability: whether the model can localize a problem on its own based on errors such as link failures, missing symbols, or out-of-bounds addresses;
    3. Architecture soundness: whether the module boundaries are clear and whether platform-specific code is isolated;
    4. Cost efficiency: how many conversation turns and how much cost the equivalent task consumes;
    5. Portability: whether a change of platform is confined to a small number of files.

    The first-hand impression from the original run was this: the model performed well at making code “look proper,” but in an environment with no supporting system, it repeatedly trialed and errored at the beginning because it was unfamiliar with the platform’s constraints. Once the project context file was in place, the later iterations went noticeably more smoothly. This reinforces a judgment: the AI-driven efficiency gains in low-level development come more from reworking the development process and supplementing knowledge than from raw code-generation speed.

    6. Reusable Practical Recommendations

    • Use a project context file to carry the goals and constraints, compressing long conversations into short instructions.
    • Advance in stages, “skeleton, input, physics, localization, polish,” and give every stage a verification method.
    • Wrap platform-specific capabilities in a thin layer so that an interface is left open for porting.
    • Proactively feed the model the local knowledge base and the official specification documents, reducing its tendency to invent interfaces that don’t exist.
    • Get the workflow running on a low-cost general-purpose model first, then bring in a higher-capability model to tackle the hard parts and keep the overall cost under control.

    In short, in a “zero-support” environment like firmware, the value of AI programming does not lie in typing on a person’s behalf, but in turning requirement description, context maintenance, and result review into a new set of core skills. Whoever gets this paradigm running smoothly first will earn a multiplied efficiency gain in BIOS creative development and platform porting.