UEFI Vertical Shooter Engineering: Graphics, Input, and Data-Driven Gameplay
This article presents a reusable engineering approach for building a vertical scrolling shooter in the preboot UEFI environment. It covers runtime constraints, GOP framebuffer rendering, nonblocking input, frame timing, object pools, a custom Chinese bitmap font, table-driven weapons, wingmen, items, and bosses, plus reproducible build documentation. It also explains how to evaluate whether AI coding assistance actually improves delivery stability.
Writing a game inside a preboot firmware environment is not the same problem as writing one on a desktop operating system. There is no window manager, no ready-made font stack, and timers and input must be connected to firmware protocols. A vertical shooter amplifies these constraints: the screen must scroll continuously, collisions must be resolved per frame, and items and boss fights can suddenly increase object counts. If an AI coding tool only generates fragments that compile, it often causes rework around environment setup, Chinese text, and the gameplay loop. If it can organize protocol selection, resource layout, and the main loop in one pass, a playable prototype within two iterations is not surprising.
The following approach turns this kind of work into a reusable practice: define runtime constraints first, then build graphics and input, handle Chinese text separately, make gameplay data-driven, and finally ensure the project can be rebuilt from build instructions even if source files are lost.
Define Runtime Constraints First
Firmware applications are usually loaded as executable images, and the entry point receives a system table and an image handle. Dependencies should be limited to standard boot services and a few common protocols; do not assume runtime libraries beyond the file system.
Four points should be fixed in the design description. First, display should use only the framebuffer provided by the Graphics Output Protocol (GOP). The mode is selected at startup and is not switched at runtime, avoiding invalid coordinates caused by a mid-run resolution change. Second, input should only poll the Simple Text Input Protocol or Simple Pointer Protocol; the game loop must not block waiting for a keypress. Third, time should use a boot service timer event or timer tick for frame intervals, with the target frame interval written as a constant and logic updates separated from drawing. Fourth, the exit path must close events, close protocols, and perform cleanup before exiting boot services; otherwise, returning to the firmware menu can leave open handles.
Once these constraints are written into the task description, later generated code has consistent boundaries, and environment setup no longer depends on trial and error.
Environment and Project Skeleton
A minimal project only needs an entry point, protocol open and close logic, a main loop, and a resource table. The directory can be split into platform adaptation, gameplay, and resources, so drawing and numeric values are not mixed in the same file.
The following entry point only expresses responsibilities; it is not a complete implementation:
EFI_STATUSEFIAPIUefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable){GAME_CTX Ctx;if (EFI_ERROR(GameInit(&Ctx, ImageHandle, SystemTable))) {return EFI_LOAD_ERROR;}while (Ctx.Running) {GamePollInput(&Ctx);GameUpdate(&Ctx);GameDraw(&Ctx);GameWaitFrame(&Ctx);}GameShutdown(&Ctx);return EFI_SUCCESS;}
During initialization, open the graphics output protocol in a fixed order, record horizontal and vertical resolution, pixel format, and bytes per row, then create the frame event. Pixel format should be handled by branches inside the pixel-writing function; a common case is 32 bits per pixel with different red, green, and blue layouts. Convert logical coordinates to a framebuffer offset in one function, and route all sprites and Chinese bitmap glyphs through it.
Keep one repeatable command on the build side: compile the firmware application, package it as a loadable image, and boot it in an emulator or on real hardware. The documentation should state the required compiler macros, entry symbol, and image type. Even if an AI coding tool loses intermediate source files, as long as the build instructions and module boundaries remain, it has a chance to restore files against the same interfaces and compile again. This is far more reliable than relying on a vague memory of what was written.
Rendering, Scrolling, and Object Limits
A vertical shooter background can use two vertically tiled starfield or terrain strips. Each frame moves them down at a fixed speed, and the part that goes beyond the screen is filled from the top of the other strip. This avoids large bitmaps and makes it easy to fill colors directly into the framebuffer.
The player, bullets, enemies, items, and wingmen are all the same type of active object: position, velocity, health, hitbox, sprite identifier, and faction. Array lengths are fixed at compile time, for example 64 bullets and 32 enemies. Frequent memory allocation inside a frame is not appropriate in a firmware environment; an object pool with a free list or Boolean occupancy flags is enough. When spawning fails, discard that shot instead of expanding the pool.
Collision can use axis-aligned bounding boxes. First perform a coarse separation by faction, then run the box test. A boss fight simply replaces ordinary enemies with larger objects that have more phases; there is no need for a separate renderer.
Do Not Treat Chinese Display as an Afterthought
The firmware text output protocol is suitable for logs, not for drawing Han characters into the framebuffer. In-game score, weapon level, and prompts should use a self-contained bitmap font.
A practical approach is to include only the glyphs the interface will use and make a fixed-width bitmap table: each glyph uses several bytes and is expanded row by row into pixels. The drawing function writes the foreground color according to the pixel format, while the background remains transparent by not writing to the buffer. Font size, line spacing, and color should be parameters, not scattered across call sites.
Chinese text problems are most likely to cause rework when they are tied to gameplay changes in the same iteration: encoding, clipping, and blending modes interfere with one another. A better order is to get the main loop running with English text or digits first, then replace the font and change only the drawing layer. Acceptance criteria are concrete: score, level, and pause prompts stay within bounds at the target resolution, do not corrupt the display, and do not depend on operating system fonts.
Make Gameplay Table-Driven, Not Branch-Heavy
Five weapon levels, wingmen, items, and bosses can all be represented as static tables.
The weapon table describes level, fire rate, bullet count, spread angle, and damage. Upgrading only increments the level index; the firing function reads the table to spawn bullets. Wingmen are secondary emitters that follow the player with an offset; the offset and fire delay are also in the table. Items use a drop table: enemy type maps to item type and probability, and picking one up changes player state and sets a duration. Bosses use a phase table to switch barrage patterns and health thresholds; when a phase ends, the next table entry is used.
Adding a weapon level or an item type is mainly a data change. Logic functions stay short, making it easier to check whether any frame performs loops beyond the budget.
For player feel, tune three values separately: horizontal and vertical speed, shooting cooldown, and invincibility frames after being hit. During invincibility frames, only the drawing flickers and no damage is resolved. Keep these values in centralized constants instead of scattering them through update functions.
Frame Timing and Playability
Update and drawing must be separate. Updates use a fixed step, and drawing only reflects the current state. If a frame overruns, drop the draw rather than accumulating multiple logic frames in one large loop; otherwise, collisions can tunnel through objects.
Input is sampled before update, and “edge this frame” must be separated from “held.” Using an edge for firing turns it into tap-fire, while a vertical shooter needs hold-to-fire. Pause must use an edge, otherwise it will toggle repeatedly.
Exit, pause, and results screens share the same object-freeze rules: during pause, enemies and bullets do not advance, but the resume key is still responsive. On the results screen, clear the bullet pool so leftover objects do not hit the player on the first frame of the next game.
How to Tell Whether Assisted Programming Is Actually More Stable
There is no need to compare model names; look at the deliverables. Does the environment select the graphics mode once and document the pixel format? Is Chinese text independent of the text output protocol? Is gameplay data-driven and bounded by object limits? Are the build instructions sufficient to rebuild modules when source files are missing and compile again? If these conditions are met, a playable version within two iterations is a reasonable outcome: the first iteration connects the entry point, display, input, and player movement; the second adds the weapon table, wingmen, items, bosses, and the Chinese bitmap font. If every iteration changes the display mode or rewrites the main loop, the problem is usually in the task boundary, not in the gameplay itself.
Autonomy should also be judged by behavior: when a file is missing, does the tool reinvent an incompatible interface, or does it fill in an implementation according to existing headers and build instructions? Only the latter keeps compiling. Therefore, context structures, object limits, and function names in headers should remain stable, while implementation files can be rewritten.
Conclusion
The key to a firmware-level vertical shooter is constraints first: graphics output, nonblocking input, a fixed frame interval, object pools, and a self-contained Chinese bitmap font. Weapons, wingmen, items, and bosses are connected to the same main loop through tables. With clear build instructions and module boundaries, later changes by humans or assisted programming do not require tearing down the environment. Following this order, a prototype can move from “able to move” to “has upgrades, has a boss, and has readable Chinese” within very few iterations, while still remaining inside a maintainable engineering structure.
